Resource: aws_apigatewayv2_api

Manages an Amazon API Gateway Version 2 API.

Example Usage

Basic WebSocket API

resource "aws_apigatewayv2_api" "example" {
  name                       = "example-websocket-api"
  protocol_type              = "WEBSOCKET"
  route_selection_expression = "$request.body.action"
}

Basic HTTP API

resource "aws_apigatewayv2_api" "example" {
  name          = "example-http-api"
  protocol_type = "HTTP"
}

Argument Reference

This resource supports the following arguments:

__Note__: If the body argument is provided, the OpenAPI specification will be used to configure the integrations and route for the HTTP API. If this argument is provided, the following resources should not be managed as separate ones, as updates may cause manual resource updates to be overwritten:

Further more, the name, description, cors_configuration, tags and version fields should be specified in the Terraform configuration and the values will override any values specified in the OpenAPI document.

The cors_configuration object supports the following:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import aws_apigatewayv2_api using the API identifier. For example:

import {
  to = aws_apigatewayv2_api.example
  id = "aabbccddee"
}

Using terraform import, import aws_apigatewayv2_api using the API identifier. For example:

% terraform import aws_apigatewayv2_api.example aabbccddee