The AWS::ApiGatewayV2::Route
resource creates a route for an API.
Create an API Gateway Route using Websockets
resource "awscc_apigatewayv2_api" "example_api" {
name = "example-websocket-api"
protocol_type = "WEBSOCKET"
route_selection_expression = "$request.body.action"
tags = {
key = "Modified By"
value = "AWSCC"
}
}
resource "aws_apigatewayv2_integration" "example_integration" {
api_id = awscc_apigatewayv2_api.example_api.id
integration_type = "MOCK"
}
resource "awscc_apigatewayv2_route" "example_route" {
api_id = awscc_apigatewayv2_api.example_api.id
route_key = "$default"
}
Create an API Gateway Route using "HTTP Proxy" integration type, note this example also uses the AWS provider
resource "awscc_apigatewayv2_api" "example_http_api" {
name = "example-http-api"
protocol_type = "HTTP"
tags = {
key = "Modified By"
value = "AWSCC"
}
}
resource "aws_apigatewayv2_integration" "example" {
api_id = awscc_apigatewayv2_api.example_http_api.id
integration_type = "HTTP_PROXY"
integration_method = "ANY"
integration_uri = "https://example.com/{proxy}"
}
resource "awscc_apigatewayv2_route" "example_http_route" {
api_id = awscc_apigatewayv2_api.example_http_api.id
route_key = "ANY /example/{proxy+}"
target = "integrations/${aws_apigatewayv2_integration.example.id}"
}
api_id
(String) The API identifier.route_key
(String) The 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
.api_key_required
(Boolean) Specifies whether an API key is required for the route. Supported only for WebSocket APIs.authorization_scopes
(List of String) The authorization scopes supported by this route.authorization_type
(String) The authorization type for the route. For WebSocket APIs, valid values are NONE
for open access, AWS_IAM
for using AWS IAM permissions, and CUSTOM
for using a Lambda authorizer. For HTTP APIs, valid values are NONE
for open access, JWT
for using JSON Web Tokens, AWS_IAM
for using AWS IAM permissions, and CUSTOM
for using a Lambda authorizer.authorizer_id
(String) The identifier of the Authorizer
resource to be associated with this route. The authorizer identifier is generated by API Gateway when you created the authorizer.model_selection_expression
(String) The model selection expression for the route. Supported only for WebSocket APIs.operation_name
(String) The operation name for the route.request_models
(String) The request models for the route. Supported only for WebSocket APIs.request_parameters
(String) The request parameters for the route. Supported only for WebSocket APIs.route_response_selection_expression
(String) The route response selection expression for the route. Supported only for WebSocket APIs.target
(String) The target for the route.id
(String) Uniquely identifies the resource.route_id
(String)Import is supported using the following syntax:
$ terraform import awscc_apigatewayv2_route.example <resource ID>