Resource: awsApigatewayv2Route
Manages an Amazon API Gateway Version 2 route. More information can be found in the Amazon API Gateway Developer Guide for WebSocket and HTTP APIs.
Example Usage
Basic
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsApigatewayv2ApiExample = new aws.apigatewayv2Api.Apigatewayv2Api(
this,
"example",
{
name: "example-websocket-api",
protocolType: "WEBSOCKET",
routeSelectionExpression: "$request.body.action",
}
);
const awsApigatewayv2RouteExample = new aws.apigatewayv2Route.Apigatewayv2Route(
this,
"example_1",
{
apiId: awsApigatewayv2ApiExample.id,
routeKey: "$default",
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsApigatewayv2RouteExample.overrideLogicalId("example");
HTTP Proxy Integration
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsApigatewayv2ApiExample = new aws.apigatewayv2Api.Apigatewayv2Api(
this,
"example",
{
name: "example-http-api",
protocolType: "HTTP",
}
);
const awsApigatewayv2IntegrationExample =
new aws.apigatewayv2Integration.Apigatewayv2Integration(this, "example_1", {
apiId: awsApigatewayv2ApiExample.id,
integrationMethod: "ANY",
integrationType: "HTTP_PROXY",
integrationUri: "https://example.com/{proxy}",
});
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsApigatewayv2IntegrationExample.overrideLogicalId("example");
const awsApigatewayv2RouteExample = new aws.apigatewayv2Route.Apigatewayv2Route(
this,
"example_2",
{
apiId: awsApigatewayv2ApiExample.id,
routeKey: "ANY /example/{proxy+}",
target: `integrations/\${${awsApigatewayv2IntegrationExample.id}}`,
}
);
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsApigatewayv2RouteExample.overrideLogicalId("example");
Argument Reference
The following arguments are supported:
apiId
- (Required) API identifier.routeKey
- (Required) Route key for the route. For HTTP APIs, the route key can be either$default
, or a combination of an HTTP method and resource path, for example,get /pets
.apiKeyRequired
- (Optional) Boolean whether an API key is required for the route. Defaults tofalse
. Supported only for WebSocket APIs.authorizationScopes
- (Optional) Authorization scopes supported by this route. The scopes are used with a JWT authorizer to authorize the method invocation.authorizationType
- (Optional) Authorization type for the route. For WebSocket APIs, valid values arenone
for open access,AWS_IAM
for using AWS IAM permissions, andcustom
for using a Lambda authorizer. For HTTP APIs, valid values arenone
for open access,jwt
for using JSON Web Tokens,AWS_IAM
for using AWS IAM permissions, andcustom
for using a Lambda authorizer. Defaults tonone
.authorizerId
- (Optional) Identifier of theawsApigatewayv2Authorizer
resource to be associated with this route.modelSelectionExpression
- (Optional) The model selection expression for the route. Supported only for WebSocket APIs.operationName
- (Optional) Operation name for the route. Must be between 1 and 64 characters in length.requestModels
- (Optional) Request models for the route. Supported only for WebSocket APIs.requestParameter
- (Optional) Request parameters for the route. Supported only for WebSocket APIs.routeResponseSelectionExpression
- (Optional) The route response selection expression for the route. Supported only for WebSocket APIs.target
- (Optional) Target for the route, of the formintegrations/
integrationId
, whereintegrationId
is the identifier of anawsApigatewayv2Integration
resource.
The requestParameter
object supports the following:
requestParameterKey
- (Required) Request parameter key. This is a request data mapping parameter.required
- (Required) Boolean whether or not the parameter is required.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
id
- Route identifier.
Import
awsApigatewayv2Route
can be imported by using the API identifier and route identifier, e.g.,
-> Note: The API Gateway managed route created as part of quick_create cannot be imported.