awscc_apigatewayv2_route (Resource)

The AWS::ApiGatewayV2::Route resource creates a route for an API.

Example Usage

Basic Example

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"
}

HTTP Proxy Example

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}"
}

Schema

Required

Optional

Read-Only

Import

Import is supported using the following syntax:

$ terraform import awscc_apigatewayv2_route.example <resource ID>