Skip to content

aws.apigatewayv2-integration resource

Description

Integration manages an API Gateway v2 integration: the connection between an API's routes and the backend that handles their requests, identified by the pair of API id and integration id. The API id, the integration type, and the AWS service action subtype are fixed at create time, so a change to any of them replaces the integration; every other input is reconciled in place by a single UpdateIntegration call sent only when something it covers changed. Integrations take no tags.

Several inputs apply to one API protocol only, a rule the service enforces because the protocol belongs to the referenced API rather than to this resource: passthrough-behavior, content-handling-strategy, request-templates, and template-selection-expression are WebSocket-only, as are the AWS, HTTP, and MOCK integration types; response-parameters, tls-config, and integration-subtype work only on HTTP APIs. integration-method is required for every type but MOCK, except that AWS and AWS_PROXY Lambda integrations default it to POST. timeout-in-millis must be between 50 and 29000 on a WebSocket API or 50 and 30000 on an HTTP API, defaulting to the maximum, and the valid integration-subtype values are the AWS service action catalog. When omitted, the server also fills connection-type as INTERNET, payload-format-version as 1.0, and, on WebSocket APIs only, passthrough-behavior as WHEN_NO_MATCH; none of these is fabricated client-side.

Removal behaves differently per field. The plain strings description, credentials-arn, integration-method, integration-uri, connection-id, and template-selection-expression clear on the next update when removed. The enum-valued connection-type, content-handling-strategy, and passthrough-behavior, along with payload-format-version and timeout-in-millis, cannot be cleared once set: removing one leaves the stored value, and moving off a VPC link is an explicit change of connection-type to INTERNET. The update API merges request-parameters, so removed keys are deleted with an explicit empty value while the rest are re-sent; request-templates has no removal sentinel, an empty string being a valid template, so a removed template key may remain on the integration. A response-parameters status code that is removed has its mappings deleted with an empty set, and a removed tls-config block is cleared with an empty object. Length limits and syntax are left to the API: connection-id (1-1024), integration-subtype (1-128), parameter values (1-512), templates (up to 32768), the response-parameters status code range, and the credentials-arn ARN form.

Source: internal/service/apigatewayv2/integration_rsrc.go:58

Example usage:

imports: {
  aws: 'github.com/cloudboss/unobin-library-aws'
}

resources: {
  example: aws.apigatewayv2-integration {
    # Set input fields here.
  }
}

Inputs

api-id

string

required

integration-type

string

required

connection-id

optional(string)

connection-type

optional(string)

content-handling-strategy

optional(string)

credentials-arn

optional(string)

description

optional(string)

integration-method

optional(string)

integration-subtype

optional(string)

integration-uri

optional(string)

passthrough-behavior

optional(string)

payload-format-version

optional(string)

request-parameters

map(string)

request-templates

map(string)

response-parameters

list(object)
list(
  object({
    status-code: string
    mappings: map(string)
  })
)

template-selection-expression

optional(string)

timeout-in-millis

optional(integer)

tls-config

optional(object)
optional(
  object({
    server-name-to-verify: optional(string)
  })
)

Input Constraints

Integration type rules

integration-type must be AWS, AWS_PROXY, HTTP, HTTP_PROXY, or MOCK.

Rule logic
Require
input.integration-type == 'AWS'
|| input.integration-type == 'AWS_PROXY'
|| input.integration-type == 'HTTP'
|| input.integration-type == 'HTTP_PROXY'
|| input.integration-type == 'MOCK'

Integration subtype rules

integration-subtype requires integration-type AWS_PROXY.

Rule logic
When
input.integration-subtype != null
Require
input.integration-type == 'AWS_PROXY'

Connection type rules

connection-type VPC_LINK requires connection-id.

Rule logic
When
input.connection-type == 'VPC_LINK'
Require
input.connection-id != null

connection-type must be INTERNET or VPC_LINK.

Rule logic
When
input.connection-type != null
Require
input.connection-type == 'INTERNET'
|| input.connection-type == 'VPC_LINK'

Content handling strategy rules

content-handling-strategy must be CONVERT_TO_BINARY or CONVERT_TO_TEXT.

Rule logic
When
input.content-handling-strategy != null
Require
input.content-handling-strategy == 'CONVERT_TO_BINARY'
|| input.content-handling-strategy == 'CONVERT_TO_TEXT'

Passthrough behavior rules

passthrough-behavior must be WHEN_NO_MATCH, NEVER, or WHEN_NO_TEMPLATES.

Rule logic
When
input.passthrough-behavior != null
Require
input.passthrough-behavior == 'WHEN_NO_MATCH'
|| input.passthrough-behavior == 'NEVER'
|| input.passthrough-behavior == 'WHEN_NO_TEMPLATES'

Payload format version rules

payload-format-version must be 1.0 or 2.0.

Rule logic
When
input.payload-format-version != null
Require
input.payload-format-version == '1.0'
|| input.payload-format-version == '2.0'

Integration method rules

integration-method must be a valid HTTP method.

Rule logic
When
input.integration-method != null
Require
input.integration-method == 'ANY'
|| input.integration-method == 'DELETE'
|| input.integration-method == 'GET'
|| input.integration-method == 'HEAD'
|| input.integration-method == 'OPTIONS'
|| input.integration-method == 'PATCH'
|| input.integration-method == 'POST'
|| input.integration-method == 'PUT'

Outputs

api-id

string

integration-id

string

integration-response-selection-expression

string