Resource: awsApigatewayv2Integration
Manages an Amazon API Gateway Version 2 integration. More information can be found in the Amazon API Gateway Developer Guide.
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";
new aws.apigatewayv2Integration.Apigatewayv2Integration(this, "example", {
apiId: "${aws_apigatewayv2_api.example.id}",
integrationType: "MOCK",
});
Lambda 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 awsLambdaFunctionExample = new aws.lambdaFunction.LambdaFunction(
this,
"example",
{
filename: "example.zip",
functionName: "Example",
handler: "index.handler",
role: "${aws_iam_role.example.arn}",
runtime: "nodejs16.x",
}
);
const awsApigatewayv2IntegrationExample =
new aws.apigatewayv2Integration.Apigatewayv2Integration(this, "example_1", {
apiId: "${aws_apigatewayv2_api.example.id}",
connectionType: "INTERNET",
contentHandlingStrategy: "CONVERT_TO_TEXT",
description: "Lambda example",
integrationMethod: "POST",
integrationType: "AWS_PROXY",
integrationUri: awsLambdaFunctionExample.invokeArn,
passthroughBehavior: "WHEN_NO_MATCH",
});
/*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");
AWS Service 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";
new aws.apigatewayv2Integration.Apigatewayv2Integration(this, "example", {
apiId: "${aws_apigatewayv2_api.example.id}",
credentialsArn: "${aws_iam_role.example.arn}",
description: "SQS example",
integrationSubtype: "SQS-SendMessage",
integrationType: "AWS_PROXY",
requestParameters: {
MessageBody: "$request.body.message",
QueueUrl: "$request.header.queueUrl",
},
});
Private 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";
new aws.apigatewayv2Integration.Apigatewayv2Integration(this, "example", {
apiId: "${aws_apigatewayv2_api.example.id}",
connectionId: "${aws_apigatewayv2_vpc_link.example.id}",
connectionType: "VPC_LINK",
credentialsArn: "${aws_iam_role.example.arn}",
description: "Example with a load balancer",
integrationMethod: "ANY",
integrationType: "HTTP_PROXY",
integrationUri: "${aws_lb_listener.example.arn}",
requestParameters: {
"append:header.authforintegration":
"$context.authorizer.authorizerResponse",
"overwrite:path": "staticValueForIntegration",
},
responseParameters: [
{
mappings: [
{
"append:headerAuth": "$context.authorizer.authorizerResponse",
},
],
statusCode: 403,
},
{
mappings: [
{
"overwrite:statuscode": "204",
},
],
statusCode: 200,
},
],
tlsConfig: {
serverNameToVerify: "example.com",
},
});
Argument Reference
The following arguments are supported:
apiId
- (Required) API identifier.integrationType
- (Required) Integration type of an integration. Valid values:aws
(supported only for WebSocket APIs),AWS_PROXY
,http
(supported only for WebSocket APIs),HTTP_PROXY
,mock
(supported only for WebSocket APIs). For an HTTP API private integration, useHTTP_PROXY
.connectionId
- (Optional) ID of the VPC link for a private integration. Supported only for HTTP APIs. Must be between 1 and 1024 characters in length.connectionType
- (Optional) Type of the network connection to the integration endpoint. Valid values:internet
,VPC_LINK
. Default isinternet
.contentHandlingStrategy
- (Optional) How to handle response payload content type conversions. Valid values:CONVERT_TO_BINARY
,CONVERT_TO_TEXT
. Supported only for WebSocket APIs.credentialsArn
- (Optional) Credentials required for the integration, if any.description
- (Optional) Description of the integration.integrationMethod
- (Optional) Integration's HTTP method. Must be specified ifintegrationType
is notmock
.integrationSubtype
- (Optional) AWS service action to invoke. Supported only for HTTP APIs whenintegrationType
isAWS_PROXY
. See the AWS service integration reference documentation for supported values. Must be between 1 and 128 characters in length.integrationUri
- (Optional) URI of the Lambda function for a Lambda proxy integration, whenintegrationType
isAWS_PROXY
. For anhttp
integration, specify a fully-qualified URL. For an HTTP API private integration, specify the ARN of an Application Load Balancer listener, Network Load Balancer listener, or AWS Cloud Map service.passthroughBehavior
- (Optional) Pass-through behavior for incoming requests based on the Content-Type header in the request, and the available mapping templates specified as therequestTemplates
attribute. Valid values:WHEN_NO_MATCH
,WHEN_NO_TEMPLATES
,never
. Default isWHEN_NO_MATCH
. Supported only for WebSocket APIs.payloadFormatVersion
- (Optional) The format of the payload sent to an integration. Valid values:10
,20
. Default is10
.requestParameters
- (Optional) For WebSocket APIs, a key-value map specifying request parameters that are passed from the method request to the backend. For HTTP APIs with a specifiedintegrationSubtype
, a key-value map specifying parameters that are passed toAWS_PROXY
integrations. For HTTP APIs without a specifiedintegrationSubtype
, a key-value map specifying how to transform HTTP requests before sending them to the backend. See the Amazon API Gateway Developer Guide for details.requestTemplates
- (Optional) Map of Velocity templates that are applied on the request payload based on the value of the Content-Type header sent by the client. Supported only for WebSocket APIs.responseParameters
- (Optional) Mappings to transform the HTTP response from a backend integration before returning the response to clients. Supported only for HTTP APIs.templateSelectionExpression
- (Optional) The template selection expression for the integration.timeoutMilliseconds
- (Optional) Custom timeout between 50 and 29,000 milliseconds for WebSocket APIs and between 50 and 30,000 milliseconds for HTTP APIs. The default timeout is 29 seconds for WebSocket APIs and 30 seconds for HTTP APIs. Terraform will only perform drift detection of its value when present in a configuration.tlsConfig
- (Optional) TLS configuration for a private integration. Supported only for HTTP APIs.
The responseParameters
object supports the following:
statusCode
- (Required) HTTP status code in the range 200-599.mappings
- (Required) Key-value map. The key of this map identifies the location of the request parameter to change, and how to change it. The corresponding value specifies the new data for the parameter. See the Amazon API Gateway Developer Guide for details.
The tlsConfig
object supports the following:
serverNameToVerify
- (Optional) If you specify a server name, API Gateway uses it to verify the hostname on the integration's certificate. The server name is also included in the TLS handshake to support Server Name Indication (SNI) or virtual hosting.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
id
- Integration identifier.integrationResponseSelectionExpression
- The integration response selection expression for the integration.
Import
awsApigatewayv2Integration
can be imported by using the API identifier and integration identifier, e.g.,
-> Note: The API Gateway managed integration created as part of quick_create cannot be imported.