Module library

API Gateway

Terraform module to create AWS API Gateway v2 (HTTP/WebSocket)

Inputs

40 / 43
api_key_selection_expressionoptionalstring

An API key selection expression. Valid values: `$context.authorizer.usageIdentifierKey`, `$request.header.x-api-key`. Defaults to `$request.header.x-api-key`. Applicable for WebSocket APIs

Defaultnull
api_mapping_keyoptionalstring

The [API mapping key](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-mapping-template-reference.html)

Defaultnull
api_versionoptionalstring

A version identifier for the API. Must be between 1 and 64 characters in length

Defaultnull
authorizersoptionalmap(object({ authorizer_credentials_arn = optional(string) authorizer_payload_fo…

Map of API gateway authorizers to create

Default{}
bodyoptionalstring

An OpenAPI specification that defines the set of routes and integrations to create as part of the HTTP APIs. Supported only for HTTP APIs

Defaultnull
cors_configurationoptionalobject({ allow_credentials = optional(bool) allow_headers = optional(list(string…

The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs

Defaultnull
createoptionalbool

Controls if resources should be created

Defaulttrue
create_certificateoptionalbool

Whether to create a certificate for the domain. Since certificate validate only works on public domains, this will be ignore if `private_zone` is set to `true`

Defaulttrue
create_domain_nameoptionalbool

Whether to create API domain name resource

Defaulttrue
create_domain_recordsoptionalbool

Whether to create Route53 records for the domain name

Defaulttrue
create_routes_and_integrationsoptionalbool

Whether to create routes and integrations resources

Defaulttrue
create_stageoptionalbool

Whether to create default stage

Defaulttrue
credentials_arnoptionalstring

Part of quick create. Specifies any credentials required for the integration. Applicable for HTTP APIs

Defaultnull
deploy_stageoptionalbool

Whether to deploy the stage. `HTTP` APIs are auto-deployed by default

Defaulttrue
descriptionoptionalstring

The description of the API. Must be less than or equal to 1024 characters in length

Defaultnull
disable_execute_api_endpointoptionalbool

Whether clients can invoke the API by using the default execute-api endpoint. By default, clients can invoke the API with the default `{api_id}.execute-api.{region}.amazonaws.com endpoint`. To require that clients use a custom domain name to invoke the API, disable the default endpoint

Defaultnull
domain_nameoptionalstring

The domain name to use for API gateway

Default""
domain_name_certificate_arnoptionalstring

The ARN of an AWS-managed certificate that will be used by the endpoint for the domain name. AWS Certificate Manager is the only supported source

Defaultnull
domain_name_ownership_verification_certificate_arnoptionalstring

ARN of the AWS-issued certificate used to validate custom domain ownership (when certificate_arn is issued via an ACM Private CA or mutual_tls_authentication is configured with an ACM-imported certificate.)

Defaultnull
fail_on_warningsoptionalbool

Whether warnings should return an error while API Gateway is creating or updating the resource using an OpenAPI specification. Defaults to `false`. Applicable for HTTP APIs

Defaultnull
hosted_zone_nameoptionalstring

Optional domain name of the Hosted Zone where the domain should be created

Defaultnull
ip_address_typeoptionalstring

The IP address types that can invoke the API. Valid values: ipv4, dualstack. Use ipv4 to allow only IPv4 addresses to invoke your API, or use dualstack to allow both IPv4 and IPv6 addresses to invoke your API. Defaults to ipv4.

Defaultnull
mutual_tls_authenticationoptionalmap(string)

The mutual TLS authentication configuration for the domain name

Default{}
nameoptionalstring

The name of the API. Must be less than or equal to 128 characters in length

Default""
private_zoneoptionalbool

Indicates the hosted zone being looked up is private. Certificate validation will fail if this is set to true.

Defaultfalse
protocol_typeoptionalstring

The API protocol. Valid values: `HTTP`, `WEBSOCKET`

DefaultHTTP
regionoptionalstring

Region where the resource(s) will be managed. Defaults to the Region set in the provider configuration

Defaultnull
route_keyoptionalstring

Part of quick create. Specifies any route key. Applicable for HTTP APIs

Defaultnull
route_selection_expressionoptionalstring

The route selection expression for the API. Defaults to `$request.method $request.path`

Defaultnull
routesoptionalmap(object({ # Route authorizer_key = optional(string) api_key_required = option…

Map of API gateway routes with integrations

Default{}
stage_access_log_settingsoptionalobject({ create_log_group = optional(bool, true) destination_arn = optional(stri…

Settings for logging access in this stage. Use the aws_api_gateway_account resource to configure [permissions for CloudWatch Logging](https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html#set-up-access-logging-permissions)

Default{}
stage_client_certificate_idoptionalstring

The identifier of a client certificate for the stage. Use the `aws_api_gateway_client_certificate` resource to configure a client certificate. Supported only for WebSocket APIs

Defaultnull
stage_default_route_settingsoptionalobject({ data_trace_enabled = optional(bool, true) detailed_metrics_enabled = op…

The default route settings for the stage

Default{}
stage_descriptionoptionalstring

The description for the stage. Must be less than or equal to 1024 characters in length

Defaultnull
stage_nameoptionalstring

The name of the stage. Must be between 1 and 128 characters in length

Default$default
stage_tagsoptionalmap(string)

A mapping of tags to assign to the stage resource

Default{}
stage_variablesoptionalmap(string)

A map that defines the stage variables for the stage

Default{}
subdomain_record_typesoptionallist(string)

A list of record types to create for the subdomain(s)

Default[…]
subdomainsoptionallist(string)

An optional list of subdomains to use for API gateway

Default[]
tagsoptionalmap(string)

A mapping of tags to assign to API gateway resources

Default{}

All 43 are optional — the module deploys with none of them set. Showing 40, so the site stays a static download — the remaining 3 are in the source.

Outputs

22
acm_certificate_arn

The ARN of the certificate

api_arn

The ARN of the API

api_endpoint

URI of the API, of the form `https://{api-id}.execute-api.{region}.amazonaws.com` for HTTP APIs and `wss://{api-id}.execute-api.{region}.amazonaws.com` for WebSocket APIs

api_execution_arn

The ARN prefix to be used in an `aws_lambda_permission`'s `source_arn` attribute or in an `aws_iam_policy` to authorize access to the `@connections` API

api_id

The API identifier

authorizers

Map of API Gateway Authorizer(s) created and their attributes

domain_name_api_mapping_selection_expression

The API mapping selection expression for the domain name

domain_name_arn

The ARN of the domain name

domain_name_configuration

The domain name configuration

domain_name_hosted_zone_id

The Amazon Route 53 Hosted Zone ID of the endpoint

domain_name_id

The domain name identifier

domain_name_target_domain_name

The target domain name

integrations

Map of the integrations created and their attributes

routes

Map of the routes created and their attributes

stage_access_logs_cloudwatch_log_group_arn

Arn of cloudwatch log group created

stage_access_logs_cloudwatch_log_group_name

Name of cloudwatch log group created

stage_arn

The stage ARN

stage_domain_name

Domain name of the stage (useful for CloudFront distribution)

stage_execution_arn

The ARN prefix to be used in an aws_lambda_permission's source_arn attribute or in an aws_iam_policy to authorize access to the @connections API

stage_id

The stage identifier

stage_invoke_url

The URL to invoke the API pointing to the stage

vpc_links

Map of VPC links created and their attributes

What the agent wires into the next module. An edge on the architecture diagram is one of these consumed by something else.