# AWS APIGatewayv2 Construct Library

## Introduction

Amazon API Gateway is an AWS service for creating, publishing, maintaining, monitoring, and securing REST, HTTP, and WebSocket
APIs at any scale. API developers can create APIs that access AWS or other web services, as well as data stored in the AWS Cloud.
As an API Gateway API developer, you can create APIs for use in your own client applications. Read the
[Amazon API Gateway Developer Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html).

This module supports features under [API Gateway v2](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGatewayV2.html)
that lets users set up Websocket and HTTP APIs.
REST APIs can be created using the `aws-cdk-lib/aws-apigateway` module.

HTTP and Websocket APIs use the same CloudFormation resources under the hood. However, this module separates them into two separate constructs for a more efficient abstraction since there are a number of CloudFormation properties that specifically apply only to each type of API.

## HTTP API

HTTP APIs enable creation of RESTful APIs that integrate with AWS Lambda functions, known as Lambda proxy integration,
or to any routable HTTP endpoint, known as HTTP proxy integration.

### Defining HTTP APIs

HTTP APIs have two fundamental concepts - Routes and Integrations.

Routes direct incoming API requests to backend resources. Routes consist of two parts: an HTTP method and a resource
path, such as, `GET /books`. Learn more at [Working with
routes](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html). Use the `ANY` method
to match any methods for a route that are not explicitly defined.

Integrations define how the HTTP API responds when a client reaches a specific Route. HTTP APIs support Lambda proxy
integration, HTTP proxy integration and, AWS service integrations, also known as private integrations. Learn more at
[Configuring integrations](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html).

Integrations are available at the `aws-apigatewayv2-integrations` module and more information is available in that module.
As an early example, we have a website for a bookstore where the following code snippet configures a route `GET /books` with an HTTP proxy integration. All other HTTP method calls to `/books` route to a default lambda proxy for the bookstore.

```ts
import { HttpUrlIntegration, HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

const getBooksIntegration = new HttpUrlIntegration('GetBooksIntegration', 'https://get-books-proxy.example.com');

declare const bookStoreDefaultFn: lambda.Function;
const bookStoreDefaultIntegration = new HttpLambdaIntegration('BooksIntegration', bookStoreDefaultFn);

const httpApi = new apigwv2.HttpApi(this, 'HttpApi');

httpApi.addRoutes({
  path: '/books',
  methods: [ apigwv2.HttpMethod.GET ],
  integration: getBooksIntegration,
});
httpApi.addRoutes({
  path: '/books',
  methods: [ apigwv2.HttpMethod.ANY ],
  integration: bookStoreDefaultIntegration,
});
```

The URL to the endpoint can be retrieved via the `apiEndpoint` attribute. By default this URL is enabled for clients. Use `disableExecuteApiEndpoint` to disable it.

```ts
const httpApi = new apigwv2.HttpApi(this, 'HttpApi', {
  disableExecuteApiEndpoint: true,
});
```

The `defaultIntegration` option while defining HTTP APIs lets you create a default catch-all integration that is
matched when a client reaches a route that is not explicitly defined.

```ts
import { HttpUrlIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

new apigwv2.HttpApi(this, 'HttpProxyApi', {
  defaultIntegration: new HttpUrlIntegration('DefaultIntegration', 'https://example.com'),
});
```

The `routeSelectionExpression` option allows configuring the HTTP API to accept only `${request.method} ${request.path}`. Setting it to `true` automatically applies this value.

```ts
new apigwv2.HttpApi(this, 'HttpProxyApi', {
  routeSelectionExpression: true,
});
```

You can configure IP address type for the API endpoint using `ipAddressType` property.
Valid values are `IPV4` (default) and `DUAL_STACK`.

```ts
new apigwv2.HttpApi(this, 'HttpApi', {
  ipAddressType: apigwv2.IpAddressType.DUAL_STACK,
});
```

### Cross Origin Resource Sharing (CORS)

[Cross-origin resource sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) is a browser security
feature that restricts HTTP requests that are initiated from scripts running in the browser. Enabling CORS will allow
requests to your API from a web application hosted in a domain different from your API domain.

When configured CORS for an HTTP API, API Gateway automatically sends a response to preflight `OPTIONS` requests, even
if there isn't an `OPTIONS` route configured. Note that, when this option is used, API Gateway will ignore CORS headers
returned from your backend integration. Learn more about [Configuring CORS for an HTTP
API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html).

The `corsPreflight` option lets you specify a CORS configuration for an API.

```ts
new apigwv2.HttpApi(this, 'HttpProxyApi', {
  corsPreflight: {
    allowHeaders: ['Authorization'],
    allowMethods: [
      apigwv2.CorsHttpMethod.GET,
      apigwv2.CorsHttpMethod.HEAD,
      apigwv2.CorsHttpMethod.OPTIONS,
      apigwv2.CorsHttpMethod.POST,
    ],
    allowOrigins: ['*'],
    maxAge: Duration.days(10),
  },
});
```

### Publishing HTTP APIs

A Stage is a logical reference to a lifecycle state of your API (for example, `dev`, `prod`, `beta`, or `v2`). API
stages are identified by their stage name. Each stage is a named reference to a deployment of the API made available for
client applications to call.

Use [`HttpStage`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpStage) to create a Stage resource for HTTP APIs. The following code sets up a Stage, whose URL is available at
`https://{api_id}.execute-api.{region}.amazonaws.com/beta`.

```ts
declare const api: apigwv2.HttpApi;

new apigwv2.HttpStage(this, 'Stage', {
  httpApi: api,
  stageName: 'beta',
  description: 'My Stage',
});
```

If you omit the `stageName` will create a `$default` stage. A `$default` stage is one that is served from the base of
the API's URL - `https://{api_id}.execute-api.{region}.amazonaws.com/`.

Note that, [`HttpApi`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpApi) will always creates a `$default` stage, unless the `createDefaultStage` property is unset.

### Custom Domain

Custom domain names are simpler and more intuitive URLs that you can provide to your API users. Custom domain name are associated to API stages.

The code snippet below creates a custom domain and configures a default domain mapping for your API that maps the
custom domain to the `$default` stage of the API.

```ts
import * as acm from 'aws-cdk-lib/aws-certificatemanager';
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

const certArn = 'arn:aws:acm:us-east-1:111111111111:certificate';
const domainName = 'example.com';

const dn = new apigwv2.DomainName(this, 'DN', {
  domainName: domainName,
  certificate: acm.Certificate.fromCertificateArn(this, 'cert', certArn),
});

declare const handler: lambda.Function;
const api = new apigwv2.HttpApi(this, 'HttpProxyProdApi', {
  defaultIntegration: new HttpLambdaIntegration('DefaultIntegration', handler),
  // https://${dn.domainName}/foo goes to prodApi $default stage
  defaultDomainMapping: {
    domainName: dn,
    mappingKey: 'foo',
  },
});
```

The IP address type for the domain name can be configured by using the `ipAddressType`
property. Valid values are `IPV4` (default) and `DUAL_STACK`.

```ts
import * as acm from 'aws-cdk-lib/aws-certificatemanager';

declare const certificate: acm.ICertificate;
declare const domainName: string;

const dn = new apigwv2.DomainName(this, 'DN', {
  domainName: domainName,
  certificate: certificate,
  ipAddressType: apigwv2.IpAddressType.DUAL_STACK,
});
```

To migrate a domain endpoint from one type to another, you can add a new endpoint configuration via `addEndpoint()`
and then configure DNS records to route traffic to the new endpoint. After that, you can remove the previous endpoint configuration.
Learn more at [Migrating a custom domain name](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-migrate.html)

To associate a specific `Stage` to a custom domain mapping -

```ts
declare const api: apigwv2.HttpApi;
declare const dn: apigwv2.DomainName;

api.addStage('beta', {
  stageName: 'beta',
  autoDeploy: true,
  // https://${dn.domainName}/bar goes to the beta stage
  domainMapping: {
    domainName: dn,
    mappingKey: 'bar',
  },
});
```

The same domain name can be associated with stages across different [`HttpApi`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpApi) as so -

```ts
import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

declare const handler: lambda.Function;
declare const dn: apigwv2.DomainName;

const apiDemo = new apigwv2.HttpApi(this, 'DemoApi', {
  defaultIntegration: new HttpLambdaIntegration('DefaultIntegration', handler),
  // https://${dn.domainName}/demo goes to apiDemo $default stage
  defaultDomainMapping: {
    domainName: dn,
    mappingKey: 'demo',
  },
});
```

The `mappingKey` determines the base path of the URL with the custom domain. Each custom domain is only allowed
to have one API mapping with undefined `mappingKey`. If more than one API mappings are specified, `mappingKey` will be required for all of them. In the sample above, the custom domain is associated
with 3 API mapping resources across different APIs and Stages.

|        API     |     Stage   |   URL  |
| :------------: | :---------: | :----: |
| api | $default  |   `https://${domainName}/foo`  |
| api | beta  |   `https://${domainName}/bar`  |
| apiDemo | $default  |   `https://${domainName}/demo`  |

You can retrieve the full domain URL with mapping key using the `domainUrl` property as so -

```ts
declare const apiDemo: apigwv2.HttpApi;
const demoDomainUrl = apiDemo.defaultStage?.domainUrl; // returns "https://example.com/demo"
```

### Mutual TLS (mTLS)

Mutual TLS can be configured to limit access to your API based by using client certificates instead of (or as an extension of) using authorization headers.

```ts
import * as s3 from 'aws-cdk-lib/aws-s3';
import * as acm from 'aws-cdk-lib/aws-certificatemanager';

const certArn = 'arn:aws:acm:us-east-1:111111111111:certificate';
const domainName = 'example.com';
declare const bucket: s3.Bucket;

new apigwv2.DomainName(this, 'DomainName', {
  domainName,
  certificate: acm.Certificate.fromCertificateArn(this, 'cert', certArn),
  mtls: {
    bucket,
    key: 'someca.pem',
    version: 'version',
  },
});
```

Instructions for configuring your trust store can be found [here](https://aws.amazon.com/blogs/compute/introducing-mutual-tls-authentication-for-amazon-api-gateway/)

### Managing access to HTTP APIs

API Gateway supports multiple mechanisms for [controlling and managing access to your HTTP
API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-access-control.html) through authorizers.

These authorizers can be found in the [APIGatewayV2-Authorizers](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2_authorizers-readme.html) constructs library.

### Metrics

The API Gateway v2 service sends metrics around the performance of HTTP APIs to Amazon CloudWatch.
These metrics can be referred to using the metric APIs available on the [`HttpApi`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpApi) construct.
The APIs with the `metric` prefix can be used to get reference to specific metrics for this API. For example,
the method below refers to the client side errors metric for this API.

```ts
const api = new apigwv2.HttpApi(this, 'my-api');
const clientErrorMetric = api.metricClientError();
```

Please note that this will return a metric for all the stages defined in the api. It is also possible to refer to metrics for a specific Stage using
the `metric` methods from the `Stage` construct.

```ts
const api = new apigwv2.HttpApi(this, 'my-api');
const stage = new apigwv2.HttpStage(this, 'Stage', {
  httpApi: api,
});
const clientErrorMetric = stage.metricClientError();
```

### VPC Link

Private integrations let HTTP APIs connect with AWS resources that are placed behind a VPC. These are usually Application
Load Balancers, Network Load Balancers or a Cloud Map service. The [`VpcLink`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.VpcLink) construct enables this integration.
The following code creates a [`VpcLink`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.VpcLink) to a private VPC.

```ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';
import * as elb from 'aws-cdk-lib/aws-elasticloadbalancingv2';
import { HttpAlbIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

const vpc = new ec2.Vpc(this, 'VPC');
const alb = new elb.ApplicationLoadBalancer(this, 'AppLoadBalancer', { vpc });

const vpcLink = new apigwv2.VpcLink(this, 'VpcLink', { vpc });

// Creating an HTTP ALB Integration:
const albIntegration = new HttpAlbIntegration('ALBIntegration', alb.listeners[0], {});
```

Any existing [`VpcLink`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.VpcLink) resource can be imported into the CDK app via the `VpcLink.fromVpcLinkAttributes()`.

```ts
import * as ec2 from 'aws-cdk-lib/aws-ec2';

declare const vpc: ec2.Vpc;
const awesomeLink = apigwv2.VpcLink.fromVpcLinkAttributes(this, 'awesome-vpc-link', {
  vpcLinkId: 'us-east-1_oiuR12Abd',
  vpc,
});
```

### Private Integration

Private integrations enable integrating an HTTP API route with private resources in a VPC, such as Application Load Balancers or
Amazon ECS container-based applications.  Using private integrations, resources in a VPC can be exposed for access by
clients outside of the VPC.

These integrations can be found in the [aws-apigatewayv2-integrations](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2_integrations-readme.html) constructs library.

### Generating ARN for Execute API

The arnForExecuteApi function in AWS CDK is designed to generate Amazon Resource Names (ARNs) for Execute API operations. This is particularly useful when you need to create ARNs dynamically based on different parameters like HTTP method, API path, and stage.

```ts
const api = new apigwv2.HttpApi(this, 'my-api');
const arn = api.arnForExecuteApi('GET', '/myApiPath', 'dev');
```

- Ensure that the path parameter, if provided, starts with '/'.
- The 'ANY' method can be used for matching any HTTP methods not explicitly defined.
- The function gracefully handles undefined parameters by using wildcards, making it flexible for various API configurations.

## WebSocket API

A WebSocket API in API Gateway is a collection of WebSocket routes that are integrated with backend HTTP endpoints,
Lambda functions, or other AWS services. You can use API Gateway features to help you with all aspects of the API
lifecycle, from creation through monitoring your production APIs. [Read more](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-overview.html)

WebSocket APIs have two fundamental concepts - Routes and Integrations.

WebSocket APIs direct JSON messages to backend integrations based on configured routes. (Non-JSON messages are directed
to the configured `$default` route.)

Integrations define how the WebSocket API behaves when a client reaches a specific Route. Learn more at
[Configuring integrations](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integration-requests.html).

Integrations are available in the `aws-apigatewayv2-integrations` module and more information is available in that module.

To add the default WebSocket routes supported by API Gateway (`$connect`, `$disconnect` and `$default`), configure them as part of api props:

```ts
import { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

declare const connectHandler: lambda.Function;
declare const disconnectHandler: lambda.Function;
declare const defaultHandler: lambda.Function;

const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi', {
  connectRouteOptions: { integration: new WebSocketLambdaIntegration('ConnectIntegration', connectHandler) },
  disconnectRouteOptions: { integration: new WebSocketLambdaIntegration('DisconnectIntegration',disconnectHandler) },
  defaultRouteOptions: { integration: new WebSocketLambdaIntegration('DefaultIntegration', defaultHandler) },
});

new apigwv2.WebSocketStage(this, 'mystage', {
  webSocketApi,
  stageName: 'dev',
  description: 'My Stage',
  autoDeploy: true,
});
```

To retrieve a websocket URL and a callback URL:

```ts
declare const webSocketStage: apigwv2.WebSocketStage;

const webSocketURL = webSocketStage.url;
// wss://${this.api.apiId}.execute-api.${s.region}.${s.urlSuffix}/${urlPath}
const callbackURL = webSocketStage.callbackUrl;
// https://${this.api.apiId}.execute-api.${s.region}.${s.urlSuffix}/${urlPath}
```

To add any other route:

```ts
import { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

declare const messageHandler: lambda.Function;
const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi');
webSocketApi.addRoute('sendmessage', {
  integration: new WebSocketLambdaIntegration('SendMessageIntegration', messageHandler),
});
```

To add a route that can return a result:

```ts
import { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';

declare const messageHandler: lambda.Function;
const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi');
webSocketApi.addRoute('sendmessage', {
  integration: new WebSocketLambdaIntegration('SendMessageIntegration', messageHandler),
  returnResponse: true,
});
```

To import an existing WebSocketApi:

```ts
const webSocketApi = apigwv2.WebSocketApi.fromWebSocketApiAttributes(this, 'mywsapi', { webSocketId: 'api-1234' });
```

To generate an ARN for Execute API:

```ts
const api = new apigwv2.WebSocketApi(this, 'mywsapi');
const arn = api.arnForExecuteApiV2('$connect', 'dev');
```

For a detailed explanation of this function, including usage and examples, please refer to the [Generating ARN for Execute API](#generating-arn-for-execute-api) section under HTTP API.

To disable schema validation, set `disableSchemaValidation` to true.

```ts
new apigwv2.WebSocketApi(this, 'api', {
  disableSchemaValidation: true,
});
```

You can configure IP address type for the API endpoint using `ipAddressType` property.
Valid values are `IPV4` (default) and `DUAL_STACK`.

```ts
new apigwv2.WebSocketApi(this, 'WebSocketApi', {
  ipAddressType: apigwv2.IpAddressType.DUAL_STACK,
});
```

### Manage Connections Permission

Grant permission to use API Gateway Management API of a WebSocket API by calling the `grantManageConnections` API.
You can use Management API to send a callback message to a connected client, get connection information, or disconnect the client. Learn more at [Use @connections commands in your backend service](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html).

```ts
declare const fn: lambda.Function;

const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi');
const stage = new apigwv2.WebSocketStage(this, 'mystage', {
  webSocketApi,
  stageName: 'dev',
});
// per stage permission
stage.grantManagementApiAccess(fn);
// for all the stages permission
webSocketApi.grantManageConnections(fn);
```

### Managing access to WebSocket APIs

API Gateway supports multiple mechanisms for [controlling and managing access to a WebSocket API](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-control-access.html) through authorizers.

These authorizers can be found in the [APIGatewayV2-Authorizers](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_apigatewayv2_authorizers-readme.html) constructs library.

### API Keys

Websocket APIs also support usage of API Keys. An API Key is a key that is used to grant access to an API. These are useful for controlling and tracking access to an API, when used together with [usage plans](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html). These together allow you to configure controls around API access such as quotas and throttling, along with per-API Key metrics on usage.

To require an API Key when accessing the Websocket API:

```ts
const webSocketApi = new apigwv2.WebSocketApi(this, 'mywsapi',{
  apiKeySelectionExpression: apigwv2.WebSocketApiKeySelectionExpression.HEADER_X_API_KEY,
});
```

## Usage Plan and API Keys

A usage plan specifies who can access one or more deployed WebSocket API stages, and the rate at which they can be accessed. The plan uses API keys to
identify API clients and meters access to the associated API stages for each key. Usage plans also allow configuring throttling limits and quota limits that are
enforced on individual client API keys.

The following example shows how to create and associate a usage plan and an API key for WebSocket APIs:

```ts
const apiKey = new apigwv2.ApiKey(this, "ApiKey");

const usagePlan = new apigwv2.UsagePlan(this, "UsagePlan", {
  usagePlanName: "WebSocketUsagePlan",
  throttle: {
    rateLimit: 10,
    burstLimit: 2
  }
});

usagePlan.addApiKey(apiKey);
```

To associate a plan to a given WebSocketAPI stage:

```ts
const api = new apigwv2.WebSocketApi(this, 'my-api');
const stage = new apigwv2.WebSocketStage(this, 'my-stage', {
  webSocketApi: api,
  stageName: 'dev',
});

const usagePlan = new apigwv2.UsagePlan(this, 'my-usage-plan', {
  usagePlanName: 'Basic',
});

usagePlan.addApiStage({
  api: api,
  stage: stage,
});
```

Existing usage plans can be imported into a CDK app using its id.

```ts
const usagePlan: apigwv2.IUsagePlan = apigwv2.UsagePlan.fromUsagePlanId(this, 'imported-usage-plan', '<usage-plan-id>');
```

The name and value of the API Key can be specified at creation; if not provided, a name and a value will be automatically generated by API Gateway.

```ts
// Auto-generated name and value
const autoKey = new apigwv2.ApiKey(this, 'AutoKey');

// Explicit name and value
const explicitKey = new apigwv2.ApiKey(this, 'ExplicitKey', {
  apiKeyName: 'MyWebSocketApiKey',
  value: 'MyApiKeyThatIsAtLeast20Characters',
});
```

Existing API keys can also be imported into a CDK app using its id.

```ts
const importedKey = apigwv2.ApiKey.fromApiKeyId(this, 'imported-key', '<api-key-id>');
```

The "grant" methods can be used to give prepackaged sets of permissions to other resources. The
following code provides read permission to an API key.

```ts
import * as iam from 'aws-cdk-lib/aws-iam';

const user = new iam.User(this, 'User');
const apiKey = new apigwv2.ApiKey(this, 'ApiKey', {
  customerId: 'test-customer',
});
apiKey.grantRead(user);
```

### Adding an API Key to an imported WebSocketApi

API Keys for WebSocket APIs are associated through Usage Plans, not directly to stages. When you import a WebSocketApi, you need to create a Usage Plan that references the
imported stage and then associate the API key with that Usage Plan.

```ts
declare const webSocketApi: apigwv2.IWebSocketApi;

const importedStage = apigwv2.WebSocketStage.fromWebSocketStageAttributes(this, 'imported-stage', {
  stageName: 'myStage',
  api: webSocketApi,
});

const apiKey = new apigwv2.ApiKey(this, 'MyApiKey');

const usagePlan = new apigwv2.UsagePlan(this, 'MyUsagePlan', {
  apiStages: [{ api: webSocketApi, stage: importedStage }],
});

usagePlan.addApiKey(apiKey);
```

### Multiple API Keys

It is possible to specify multiple API keys for a given Usage Plan, by calling `usagePlan.addApiKey()`.

When using multiple API keys, you may need to ensure that the CloudFormation logical ids of the API keys remain consistent across deployments. You can set the logical id as part of the `addApiKey()` method

```ts
declare const usagePlan: apigwv2.UsagePlan;
declare const apiKey: apigwv2.ApiKey;

usagePlan.addApiKey(apiKey, {
 overrideLogicalId: 'MyCustomLogicalId',
});
```

### Rate Limited API Key

In scenarios where you need to create a single api key and configure rate limiting for it, you can use [`RateLimitedApiKey`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.RateLimitedApiKey).
This construct lets you specify rate limiting properties which should be applied only to the api key being created.
The API key created has the specified rate limits, such as quota and throttles, applied.

The following example shows how to use a rate limited api key :

```ts
declare const api: apigwv2.WebSocketApi;
declare const stage: apigwv2.WebSocketStage;

const key = new apigwv2.RateLimitedApiKey(this, 'rate-limited-api-key', {
  customerId: 'test-customer',
  apiStages: [{
    api: api,
    stage: stage
  }],
  quota: {
    limit: 10000,
    period: apigwv2.Period.MONTH
  },
  throttle: {
    rateLimit: 100,
    burstLimit: 200
  }
});
```

## Common Config

Common config for both HTTP API and WebSocket API

### Route Settings

Represents a collection of route settings.

```ts
declare const api: apigwv2.HttpApi;

new apigwv2.HttpStage(this, 'Stage', {
  httpApi: api,
  throttle: {
    rateLimit: 1000,
    burstLimit: 1000,
  },
  detailedMetricsEnabled: true,
});
```

### Access Logging

You can turn on logging to write logs to CloudWatch Logs.
Read more at Configure logging for [HTTP APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-logging.html) or [WebSocket APIs](https://docs.aws.amazon.com/apigateway/latest/developerguide/websocket-api-logging.html)

```ts
import * as logs from 'aws-cdk-lib/aws-logs';

declare const httpApi: apigwv2.HttpApi;
declare const webSocketApi : apigwv2.WebSocketApi;
declare const logGroup: logs.LogGroup;

new apigwv2.HttpStage(this, 'HttpStage', {
  httpApi,
  accessLogSettings: {
    destination: new apigwv2.LogGroupLogDestination(logGroup),
  },
});

new apigwv2.WebSocketStage(this, 'WebSocketStage', {
  webSocketApi,
  stageName: 'dev',
  accessLogSettings: {
    destination: new apigwv2.LogGroupLogDestination(logGroup),
  },
});
```

The following code will generate the access log in the [CLF format](https://en.wikipedia.org/wiki/Common_Log_Format).

```ts
import * as apigw from 'aws-cdk-lib/aws-apigateway';
import * as logs from 'aws-cdk-lib/aws-logs';

declare const api: apigwv2.HttpApi;
declare const logGroup: logs.LogGroup;

const stage = new apigwv2.HttpStage(this, 'Stage', {
  httpApi: api,
  accessLogSettings: {
    destination: new apigwv2.LogGroupLogDestination(logGroup),
    format: apigw.AccessLogFormat.clf(),
  },
});
```

You can also configure your own access log format by using the `AccessLogFormat.custom()` API.
`AccessLogField` provides commonly used fields. The following code configures access log to contain.

```ts
import * as apigw from 'aws-cdk-lib/aws-apigateway';
import * as logs from 'aws-cdk-lib/aws-logs';

declare const api: apigwv2.HttpApi;
declare const logGroup: logs.LogGroup;

const stage = new apigwv2.HttpStage(this, 'Stage', {
  httpApi: api,
  accessLogSettings: {
    destination: new apigwv2.LogGroupLogDestination(logGroup),
    format: apigw.AccessLogFormat.custom(
      `${apigw.AccessLogField.contextRequestId()} ${apigw.AccessLogField.contextErrorMessage()} ${apigw.AccessLogField.contextErrorMessageString()}
      ${apigw.AccessLogField.contextAuthorizerError()} ${apigw.AccessLogField.contextAuthorizerIntegrationStatus()}`
    ),
  },
});
```

## Types

| Name | Kind | Summary |
| --- | --- | --- |
| [`ApiKey`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.ApiKey) | Construct (L2) | An API Gateway ApiKey. |
| [`ApiMapping`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.ApiMapping) | Construct (L2) | Create a new API mapping for API Gateway API endpoint. |
| [`DomainName`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.DomainName) | Construct (L2) | Custom domain resource for the API. |
| [`HttpApi`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpApi) | Construct (L2) | Create a new API Gateway HTTP API endpoint. |
| [`HttpAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpAuthorizer) | Construct (L2) | An authorizer for Http Apis. |
| [`HttpIntegration`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpIntegration) | Construct (L2) | The integration for an API route. |
| [`HttpRoute`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRoute) | Construct (L2) | Route class that creates the Route for API Gateway HTTP API. |
| [`HttpStage`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpStage) | Construct (L2) | Represents a stage where an instance of the API is deployed. |
| [`RateLimitedApiKey`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.RateLimitedApiKey) | Construct (L2) | An API Gateway ApiKey, for which a rate limiting configuration can be specified. |
| [`UsagePlan`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.UsagePlan) | Construct (L2) | A UsagePlan. |
| [`VpcLink`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.VpcLink) | Construct (L2) | Define a new VPC Link Specifies an API Gateway VPC link for a HTTP API to access resources in an Amazon Virtual Private Cloud (VPC). |
| [`WebSocketApi`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApi) | Construct (L2) | Create a new API Gateway WebSocket API endpoint. |
| [`WebSocketAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketAuthorizer) | Construct (L2) | An authorizer for WebSocket Apis. |
| [`WebSocketIntegration`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketIntegration) | Construct (L2) | The integration for an API route. |
| [`WebSocketRoute`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRoute) | Construct (L2) | Route class that creates the Route for API Gateway WebSocket API. |
| [`WebSocketStage`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketStage) | Construct (L2) | Represents a stage where an instance of the API is deployed. |
| [`CfnApi`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApi) | Construct (L1) | The `AWS::ApiGatewayV2::Api` resource creates an API. |
| [`CfnApiGatewayManagedOverrides`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiGatewayManagedOverrides) | Construct (L1) | The `AWS::ApiGatewayV2::ApiGatewayManagedOverrides` resource overrides the default properties of API Gateway-managed resources that are implicitly configured for you when you use quick create. |
| [`CfnApiMapping`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiMapping) | Construct (L1) | The `AWS::ApiGatewayV2::ApiMapping` resource contains an API mapping. |
| [`CfnAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnAuthorizer) | Construct (L1) | The `AWS::ApiGatewayV2::Authorizer` resource creates an authorizer for a WebSocket API or an HTTP API. |
| [`CfnDeployment`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnDeployment) | Construct (L1) | The `AWS::ApiGatewayV2::Deployment` resource creates a deployment for an API. |
| [`CfnDomainName`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnDomainName) | Construct (L1) | The `AWS::ApiGatewayV2::DomainName` resource specifies a custom domain name for your API in Amazon API Gateway (API Gateway). |
| [`CfnIntegration`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnIntegration) | Construct (L1) | The `AWS::ApiGatewayV2::Integration` resource creates an integration for an API. |
| [`CfnIntegrationResponse`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnIntegrationResponse) | Construct (L1) | The `AWS::ApiGatewayV2::IntegrationResponse` resource updates an integration response for an WebSocket API. |
| [`CfnModel`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnModel) | Construct (L1) | The `AWS::ApiGatewayV2::Model` resource updates data model for a WebSocket API. |
| [`CfnPortalProduct`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnPortalProduct) | Construct (L1) | Represents a portal product in Amazon API Gateway V2, which is a logical grouping of APIs that can be published in a developer portal. |
| [`CfnRoute`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoute) | Construct (L1) | The `AWS::ApiGatewayV2::Route` resource creates a route for an API. |
| [`CfnRouteResponse`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRouteResponse) | Construct (L1) | The `AWS::ApiGatewayV2::RouteResponse` resource creates a route response for a WebSocket API. |
| [`CfnRoutingRule`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoutingRule) | Construct (L1) | Represents a routing rule. |
| [`CfnStage`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnStage) | Construct (L1) | The `AWS::ApiGatewayV2::Stage` resource specifies a stage for an API. |
| [`CfnVpcLink`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnVpcLink) | Construct (L1) | The `AWS::ApiGatewayV2::VpcLink` resource creates a VPC link. |
| [`AccessLogDestinationConfig`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.AccessLogDestinationConfig) | Struct | Options when binding a log destination to a HttpApi Stage. |
| [`AddApiKeyOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.AddApiKeyOptions) | Struct | Options to the UsagePlan.addApiKey() method. |
| [`AddRoutesOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.AddRoutesOptions) | Struct | Options for the Route with Integration resource. |
| [`ApiKeyOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.ApiKeyOptions) | Struct | The options for creating an API Key. |
| [`ApiKeyProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.ApiKeyProps) | Struct | ApiKey Properties. |
| [`ApiMappingAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.ApiMappingAttributes) | Struct | The attributes used to import existing ApiMapping. |
| [`ApiMappingProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.ApiMappingProps) | Struct | Properties used to create the ApiMapping resource. |
| [`AuthorizerPayloadVersion`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.AuthorizerPayloadVersion) | Enum | Payload format version for lambda authorizers. |
| [`BatchHttpRouteOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.BatchHttpRouteOptions) | Struct | Options used when configuring multiple routes, at once. |
| [`CfnApi.BodyS3LocationProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApi.BodyS3LocationProperty) | Struct | The `BodyS3Location` property specifies an S3 location from which to import an OpenAPI definition. |
| [`CfnApi.CorsProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApi.CorsProperty) | Struct | The `Cors` property specifies a CORS configuration for an API. |
| [`CfnApiGatewayManagedOverrides.AccessLogSettingsProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiGatewayManagedOverrides.AccessLogSettingsProperty) | Struct | The `AccessLogSettings` property overrides the access log settings for an API Gateway-managed stage. |
| [`CfnApiGatewayManagedOverrides.IntegrationOverridesProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiGatewayManagedOverrides.IntegrationOverridesProperty) | Struct | The `IntegrationOverrides` property overrides the integration settings for an API Gateway-managed integration. |
| [`CfnApiGatewayManagedOverrides.RouteOverridesProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiGatewayManagedOverrides.RouteOverridesProperty) | Struct | The `RouteOverrides` property overrides the route configuration for an API Gateway-managed route. |
| [`CfnApiGatewayManagedOverrides.RouteSettingsProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiGatewayManagedOverrides.RouteSettingsProperty) | Struct | The `RouteSettings` property overrides the route settings for an API Gateway-managed route. |
| [`CfnApiGatewayManagedOverrides.StageOverridesProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiGatewayManagedOverrides.StageOverridesProperty) | Struct | The `StageOverrides` property overrides the stage configuration for an API Gateway-managed stage. |
| [`CfnApiGatewayManagedOverridesProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiGatewayManagedOverridesProps) | Struct | Properties for defining a `CfnApiGatewayManagedOverrides`. |
| [`CfnApiMappingProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiMappingProps) | Struct | Properties for defining a `CfnApiMapping`. |
| [`CfnApiProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnApiProps) | Struct | Properties for defining a `CfnApi`. |
| [`CfnAuthorizer.JWTConfigurationProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnAuthorizer.JWTConfigurationProperty) | Struct | The `JWTConfiguration` property specifies the configuration of a JWT authorizer. |
| [`CfnAuthorizerProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnAuthorizerProps) | Struct | Properties for defining a `CfnAuthorizer`. |
| [`CfnDeploymentProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnDeploymentProps) | Struct | Properties for defining a `CfnDeployment`. |
| [`CfnDomainName.DomainNameConfigurationProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnDomainName.DomainNameConfigurationProperty) | Struct | The `DomainNameConfiguration` property type specifies the configuration for an API's domain name. |
| [`CfnDomainName.MutualTlsAuthenticationProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnDomainName.MutualTlsAuthenticationProperty) | Struct | If specified, API Gateway performs two-way authentication between the client and the server. |
| [`CfnDomainNameProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnDomainNameProps) | Struct | Properties for defining a `CfnDomainName`. |
| [`CfnIntegration.ResponseParameterListProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnIntegration.ResponseParameterListProperty) | Struct |  |
| [`CfnIntegration.ResponseParameterMapProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnIntegration.ResponseParameterMapProperty) | Struct | map of response parameter lists. |
| [`CfnIntegration.ResponseParameterProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnIntegration.ResponseParameterProperty) | Struct | Supported only for HTTP APIs. |
| [`CfnIntegration.TlsConfigProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnIntegration.TlsConfigProperty) | Struct | The `TlsConfig` property specifies the TLS configuration for a private integration. |
| [`CfnIntegrationProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnIntegrationProps) | Struct | Properties for defining a `CfnIntegration`. |
| [`CfnIntegrationResponseProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnIntegrationResponseProps) | Struct | Properties for defining a `CfnIntegrationResponse`. |
| [`CfnModelProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnModelProps) | Struct | Properties for defining a `CfnModel`. |
| [`CfnPortalProductProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnPortalProductProps) | Struct | Properties for defining a `CfnPortalProduct`. |
| [`CfnRoute.ParameterConstraintsProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoute.ParameterConstraintsProperty) | Struct |  |
| [`CfnRouteProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRouteProps) | Struct | Properties for defining a `CfnRoute`. |
| [`CfnRouteResponse.ParameterConstraintsProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRouteResponse.ParameterConstraintsProperty) | Struct | Specifies whether the parameter is required. |
| [`CfnRouteResponseProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRouteResponseProps) | Struct | Properties for defining a `CfnRouteResponse`. |
| [`CfnRoutingRule.ActionInvokeApiProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoutingRule.ActionInvokeApiProperty) | Struct | Represents an InvokeApi action. |
| [`CfnRoutingRule.ActionProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoutingRule.ActionProperty) | Struct | Represents a routing rule action. |
| [`CfnRoutingRule.ConditionProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoutingRule.ConditionProperty) | Struct | Represents a condition. |
| [`CfnRoutingRule.MatchBasePathsProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoutingRule.MatchBasePathsProperty) | Struct | Represents a `MatchBasePaths` condition. |
| [`CfnRoutingRule.MatchHeadersProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoutingRule.MatchHeadersProperty) | Struct | Represents a `MatchHeaders` condition. |
| [`CfnRoutingRule.MatchHeaderValueProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoutingRule.MatchHeaderValueProperty) | Struct | Represents a `MatchHeaderValue` . |
| [`CfnRoutingRuleProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnRoutingRuleProps) | Struct | Properties for defining a `CfnRoutingRule`. |
| [`CfnStage.AccessLogSettingsProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnStage.AccessLogSettingsProperty) | Struct | Settings for logging access in a stage. |
| [`CfnStage.RouteSettingsProperty`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnStage.RouteSettingsProperty) | Struct | Represents a collection of route settings. |
| [`CfnStageProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnStageProps) | Struct | Properties for defining a `CfnStage`. |
| [`CfnVpcLinkProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CfnVpcLinkProps) | Struct | Properties for defining a `CfnVpcLink`. |
| [`ContentHandling`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.ContentHandling) | Enum | Integration content handling. |
| [`CorsHttpMethod`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CorsHttpMethod) | Enum | Supported CORS HTTP methods. |
| [`CorsPreflightOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.CorsPreflightOptions) | Struct | Options for the CORS Configuration. |
| [`DomainMappingOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.DomainMappingOptions) | Struct | Options for DomainMapping. |
| [`DomainNameAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.DomainNameAttributes) | Struct | custom domain name attributes. |
| [`DomainNameProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.DomainNameProps) | Struct | properties used for creating the DomainName. |
| [`EndpointOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.EndpointOptions) | Struct | properties for creating a domain name endpoint. |
| [`EndpointType`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.EndpointType) | Enum | Endpoint type for a domain name. |
| [`GrantInvokeOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.GrantInvokeOptions) | Struct | Options for granting invoke access. |
| [`HttpApiAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpApiAttributes) | Struct | Attributes for importing an HttpApi into the CDK. |
| [`HttpApiHelper`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpApiHelper) | Facade | Calculations and operations for HTTP APIs. |
| [`HttpApiProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpApiProps) | Struct | Properties to initialize an instance of `HttpApi`. |
| [`HttpAuthorizerAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpAuthorizerAttributes) | Struct | Reference to an http authorizer. |
| [`HttpAuthorizerProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpAuthorizerProps) | Struct | Properties to initialize an instance of `HttpAuthorizer`. |
| [`HttpAuthorizerType`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpAuthorizerType) | Enum | Supported Authorizer types. |
| [`HttpConnectionType`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpConnectionType) | Enum | Supported connection types. |
| [`HttpIntegrationProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpIntegrationProps) | Struct | The integration properties. |
| [`HttpIntegrationSubtype`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpIntegrationSubtype) | Enum | Supported integration subtypes. |
| [`HttpIntegrationType`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpIntegrationType) | Enum | Supported integration types. |
| [`HttpMethod`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpMethod) | Enum | Supported HTTP methods. |
| [`HttpNoneAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpNoneAuthorizer) | Class | Explicitly configure no authorizers on specific HTTP API routes. |
| [`HttpRouteAuthorizerBindOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteAuthorizerBindOptions) | Struct | Input to the bind() operation, that binds an authorizer to a route. |
| [`HttpRouteAuthorizerConfig`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteAuthorizerConfig) | Struct | Results of binding an authorizer to an http route. |
| [`HttpRouteIntegration`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteIntegration) | Class | The interface that various route integration classes will inherit. |
| [`HttpRouteIntegrationBindOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteIntegrationBindOptions) | Struct | Options to the HttpRouteIntegration during its bind operation. |
| [`HttpRouteIntegrationConfig`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteIntegrationConfig) | Struct | Config returned back as a result of the bind. |
| [`HttpRouteKey`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteKey) | Class | HTTP route in APIGateway is a combination of the HTTP method and the path component. |
| [`HttpRouteProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpRouteProps) | Struct | Properties to initialize a new Route. |
| [`HttpStageAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpStageAttributes) | Struct | The attributes used to import existing HttpStage. |
| [`HttpStageOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpStageOptions) | Struct | The options to create a new Stage for an HTTP API. |
| [`HttpStageProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.HttpStageProps) | Struct | Properties to initialize an instance of `HttpStage`. |
| [`IAccessLogDestination`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IAccessLogDestination) | Interface | Access log destination for a HttpApi Stage. |
| [`IAccessLogSettings`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IAccessLogSettings) | Interface | Settings for access logging. |
| [`IApi`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IApi) | Interface | Represents a API Gateway HTTP/WebSocket API. |
| [`IApiKey`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IApiKey) | Interface | API keys are alphanumeric string values that you distribute to app developer customers to grant access to your API. |
| [`IApiMapping`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IApiMapping) | Interface | Represents an ApiGatewayV2 ApiMapping resource. |
| [`IAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IAuthorizer) | Interface | Represents an Authorizer. |
| [`IDomainName`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IDomainName) | Interface | Represents an APIGatewayV2 DomainName. |
| [`IHttpApi`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpApi) | Interface | Represents an HTTP API. |
| [`IHttpApiRef`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpApiRef) | Interface | Represents a reference to an HTTP API. |
| [`IHttpAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpAuthorizer) | Interface | An authorizer for HTTP APIs. |
| [`IHttpIntegration`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpIntegration) | Interface | Represents an Integration for an HTTP API. |
| [`IHttpRoute`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpRoute) | Interface | Represents a Route for an HTTP API. |
| [`IHttpRouteAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpRouteAuthorizer) | Interface | An authorizer that can attach to an Http Route. |
| [`IHttpStage`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpStage) | Interface | Represents the HttpStage. |
| [`IHttpStageRef`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IHttpStageRef) | Interface | Represents a reference to an HTTP Stage. |
| [`IIntegration`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IIntegration) | Interface | Represents an integration to an API Route. |
| [`IMappingValue`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IMappingValue) | Interface | Represents a Mapping Value. |
| [`IntegrationCredentials`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IntegrationCredentials) | Class | Credentials used for AWS Service integrations. |
| [`IpAddressType`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IpAddressType) | Enum | Supported IP Address Types. |
| [`IRoute`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IRoute) | Interface | Represents a route. |
| [`IStage`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IStage) | Interface | Represents a Stage. |
| [`IUsagePlan`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IUsagePlan) | Interface | A UsagePlan, either managed by this CDK app, or imported. |
| [`IVpcLink`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IVpcLink) | Interface | Represents an API Gateway VpcLink. |
| [`IWebSocketApi`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IWebSocketApi) | Interface | Represents a WebSocket API. |
| [`IWebSocketApiRef`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IWebSocketApiRef) | Interface | Represents a reference to an HTTP API. |
| [`IWebSocketAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IWebSocketAuthorizer) | Interface | An authorizer for WebSocket APIs. |
| [`IWebSocketIntegration`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IWebSocketIntegration) | Interface | Represents an Integration for an WebSocket API. |
| [`IWebSocketRoute`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IWebSocketRoute) | Interface | Represents a Route for an WebSocket API. |
| [`IWebSocketRouteAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IWebSocketRouteAuthorizer) | Interface | An authorizer that can attach to an WebSocket Route. |
| [`IWebSocketStage`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.IWebSocketStage) | Interface | Represents the WebSocketStage. |
| [`LogGroupLogDestination`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.LogGroupLogDestination) | Class | Use CloudWatch Logs as a custom access log destination for API Gateway. |
| [`MappingValue`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.MappingValue) | Class | Represents a Mapping Value. |
| [`MTLSConfig`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.MTLSConfig) | Struct | The mTLS authentication configuration for a custom domain name. |
| [`ParameterMapping`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.ParameterMapping) | Class | Represents a Parameter Mapping. |
| [`PassthroughBehavior`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.PassthroughBehavior) | Enum | Integration Passthrough Behavior. |
| [`PayloadFormatVersion`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.PayloadFormatVersion) | Class | Payload format version for lambda proxy integration. |
| [`Period`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.Period) | Enum | Time period for which quota settings apply. |
| [`QuotaSettings`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.QuotaSettings) | Struct | Specifies the maximum number of requests that clients can make to API Gateway APIs. |
| [`RateLimitedApiKeyProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.RateLimitedApiKeyProps) | Struct | RateLimitedApiKey properties. |
| [`SecurityPolicy`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.SecurityPolicy) | Enum | The minimum version of the SSL protocol that you want API Gateway to use for HTTPS connections. |
| [`StageAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.StageAttributes) | Struct | The attributes used to import existing Stage. |
| [`StageOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.StageOptions) | Struct | Options required to create a new stage. |
| [`ThrottleSettings`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.ThrottleSettings) | Struct | Container for defining throttling parameters to API stages. |
| [`UsagePlanPerApiStage`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.UsagePlanPerApiStage) | Struct | Represents the API stages that a usage plan applies to. |
| [`UsagePlanProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.UsagePlanProps) | Struct | Properties for defining an API Gateway Usage Plan for WebSocket APIs. |
| [`VpcLinkAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.VpcLinkAttributes) | Struct | Attributes when importing a new VpcLink. |
| [`VpcLinkProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.VpcLinkProps) | Struct | Properties for a VpcLink. |
| [`WebSocketApiAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApiAttributes) | Struct | Attributes for importing a WebSocketApi into the CDK. |
| [`WebSocketApiKeySelectionExpression`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApiKeySelectionExpression) | Class | Represents the currently available API Key Selection Expressions. |
| [`WebSocketApiProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketApiProps) | Struct | Props for WebSocket API. |
| [`WebSocketAuthorizerAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketAuthorizerAttributes) | Struct | Reference to an WebSocket authorizer. |
| [`WebSocketAuthorizerProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketAuthorizerProps) | Struct | Properties to initialize an instance of `WebSocketAuthorizer`. |
| [`WebSocketAuthorizerType`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketAuthorizerType) | Enum | Supported Authorizer types. |
| [`WebSocketIntegrationProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketIntegrationProps) | Struct | The integration properties. |
| [`WebSocketIntegrationType`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketIntegrationType) | Enum | WebSocket Integration Types. |
| [`WebSocketNoneAuthorizer`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketNoneAuthorizer) | Class | Explicitly configure no authorizers on specific WebSocket API routes. |
| [`WebSocketRouteAuthorizerBindOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRouteAuthorizerBindOptions) | Struct | Input to the bind() operation, that binds an authorizer to a route. |
| [`WebSocketRouteAuthorizerConfig`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRouteAuthorizerConfig) | Struct | Results of binding an authorizer to an WebSocket route. |
| [`WebSocketRouteIntegration`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRouteIntegration) | Class | The interface that various route integration classes will inherit. |
| [`WebSocketRouteIntegrationBindOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRouteIntegrationBindOptions) | Struct | Options to the WebSocketRouteIntegration during its bind operation. |
| [`WebSocketRouteIntegrationConfig`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRouteIntegrationConfig) | Struct | Config returned back as a result of the bind. |
| [`WebSocketRouteOptions`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRouteOptions) | Struct | Options used to add route to the API. |
| [`WebSocketRouteProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketRouteProps) | Struct | Properties to initialize a new Route. |
| [`WebSocketStageAttributes`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketStageAttributes) | Struct | The attributes used to import existing WebSocketStage. |
| [`WebSocketStageProps`](/v2/docs/aws-cdk-lib.aws_apigatewayv2.WebSocketStageProps) | Struct | Properties to initialize an instance of `WebSocketStage`. |
