Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,19 @@ module "api_gateway" {
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.96 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.0.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.96 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.0.0 |

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_acm"></a> [acm](#module\_acm) | terraform-aws-modules/acm/aws | 5.0.1 |
| <a name="module_acm"></a> [acm](#module\_acm) | terraform-aws-modules/acm/aws | 6.1.0 |

## Resources

Expand Down Expand Up @@ -239,6 +239,7 @@ module "api_gateway" {
| <a name="input_mutual_tls_authentication"></a> [mutual\_tls\_authentication](#input\_mutual\_tls\_authentication) | The mutual TLS authentication configuration for the domain name | `map(string)` | `{}` | no |
| <a name="input_name"></a> [name](#input\_name) | The name of the API. Must be less than or equal to 128 characters in length | `string` | `""` | no |
| <a name="input_protocol_type"></a> [protocol\_type](#input\_protocol\_type) | The API protocol. Valid values: `HTTP`, `WEBSOCKET` | `string` | `"HTTP"` | no |
| <a name="input_region"></a> [region](#input\_region) | The AWS region to create resources in | `string` | `null` | no |
| <a name="input_route_key"></a> [route\_key](#input\_route\_key) | Part of quick create. Specifies any route key. Applicable for HTTP APIs | `string` | `null` | no |
| <a name="input_route_selection_expression"></a> [route\_selection\_expression](#input\_route\_selection\_expression) | The route selection expression for the API. Defaults to `$request.method $request.path` | `string` | `null` | no |
| <a name="input_routes"></a> [routes](#input\_routes) | Map of API gateway routes with integrations | <pre>map(object({<br/> # Route<br/> authorizer_key = optional(string)<br/> api_key_required = optional(bool)<br/> authorization_scopes = optional(list(string), [])<br/> authorization_type = optional(string)<br/> authorizer_id = optional(string)<br/> model_selection_expression = optional(string)<br/> operation_name = optional(string)<br/> request_models = optional(map(string), {})<br/> request_parameter = optional(object({<br/> request_parameter_key = optional(string)<br/> required = optional(bool, false)<br/> }), {})<br/> route_response_selection_expression = optional(string)<br/><br/> # Route settings<br/> data_trace_enabled = optional(bool)<br/> detailed_metrics_enabled = optional(bool)<br/> logging_level = optional(string)<br/> throttling_burst_limit = optional(number)<br/> throttling_rate_limit = optional(number)<br/><br/> # Stage - Route response<br/> route_response = optional(object({<br/> create = optional(bool, false)<br/> model_selection_expression = optional(string)<br/> response_models = optional(map(string))<br/> route_response_key = optional(string, "$default")<br/> }), {})<br/><br/> # Integration<br/> integration = object({<br/> connection_id = optional(string)<br/> vpc_link_key = optional(string)<br/> connection_type = optional(string)<br/> content_handling_strategy = optional(string)<br/> credentials_arn = optional(string)<br/> description = optional(string)<br/> method = optional(string)<br/> subtype = optional(string)<br/> type = optional(string, "AWS_PROXY")<br/> uri = optional(string)<br/> passthrough_behavior = optional(string)<br/> payload_format_version = optional(string)<br/> request_parameters = optional(map(string), {})<br/> request_templates = optional(map(string), {})<br/> response_parameters = optional(list(object({<br/> mappings = map(string)<br/> status_code = string<br/> })))<br/> template_selection_expression = optional(string)<br/> timeout_milliseconds = optional(number)<br/> tls_config = optional(object({<br/> server_name_to_verify = optional(string)<br/> }))<br/><br/> # Integration Response<br/> response = optional(object({<br/> content_handling_strategy = optional(string)<br/> integration_response_key = optional(string)<br/> response_templates = optional(map(string))<br/> template_selection_expression = optional(string)<br/> }), {})<br/> })<br/> }))</pre> | `{}` | no |
Expand Down
28 changes: 27 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ resource "aws_apigatewayv2_api" "this" {
target = local.is_http ? var.target : null
version = var.api_version

region = var.region

tags = merge(
{ terraform-aws-modules = "apigateway-v2" },
var.tags,
Expand Down Expand Up @@ -74,6 +76,8 @@ resource "aws_apigatewayv2_authorizer" "this" {
}

name = coalesce(each.value.name, each.key)

region = var.region
}

################################################################################
Expand Down Expand Up @@ -106,6 +110,8 @@ resource "aws_apigatewayv2_domain_name" "this" {
}
}

region = var.region

tags = var.tags
}

Expand All @@ -116,6 +122,8 @@ resource "aws_apigatewayv2_api_mapping" "this" {
api_mapping_key = var.api_mapping_key
domain_name = aws_apigatewayv2_domain_name.this[0].id
stage = aws_apigatewayv2_stage.this[0].id

region = var.region
}

################################################################################
Expand Down Expand Up @@ -165,7 +173,7 @@ locals {

module "acm" {
source = "terraform-aws-modules/acm/aws"
version = "5.0.1"
version = "6.1.0"

create_certificate = local.create_domain_name && var.create_domain_records && local.create_certificate

Expand All @@ -175,6 +183,8 @@ module "acm" {

validation_method = "DNS"

region = var.region

tags = var.tags
}

Expand Down Expand Up @@ -207,6 +217,8 @@ resource "aws_apigatewayv2_route" "this" {
route_key = each.key
route_response_selection_expression = local.is_websocket ? each.value.route_response_selection_expression : null
target = "integrations/${aws_apigatewayv2_integration.this[each.key].id}"

region = var.region
}

################################################################################
Expand All @@ -221,6 +233,8 @@ resource "aws_apigatewayv2_route_response" "this" {
response_models = each.value.route_response.response_models
route_id = aws_apigatewayv2_route.this[each.key].id
route_response_key = each.value.route_response.route_response_key

region = var.region
}

################################################################################
Expand Down Expand Up @@ -269,6 +283,8 @@ resource "aws_apigatewayv2_integration" "this" {
lifecycle {
create_before_destroy = true
}

region = var.region
}

################################################################################
Expand All @@ -285,6 +301,8 @@ resource "aws_apigatewayv2_integration_response" "this" {
integration_response_key = each.value.response.integration_response_key
response_templates = each.value.response.response_templates
template_selection_expression = each.value.response.template_selection_expression

region = var.region
}

################################################################################
Expand Down Expand Up @@ -373,6 +391,8 @@ resource "aws_apigatewayv2_stage" "this" {
depends_on = [
aws_apigatewayv2_route.this
]

region = var.region
}

################################################################################
Expand Down Expand Up @@ -403,6 +423,8 @@ resource "aws_apigatewayv2_deployment" "this" {
lifecycle {
create_before_destroy = true
}

region = var.region
}

################################################################################
Expand All @@ -419,6 +441,8 @@ resource "aws_cloudwatch_log_group" "this" {
log_group_class = each.value.log_group_class

tags = merge(var.tags, each.value.log_group_tags)

region = var.region
}

################################################################################
Expand All @@ -433,4 +457,6 @@ resource "aws_apigatewayv2_vpc_link" "this" {
subnet_ids = each.value.subnet_ids

tags = merge(var.tags, var.vpc_link_tags, try(each.value.tags, {}))

region = var.region
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ variable "create" {
default = true
}

variable "region" {
description = "The AWS region to create resources in"
type = string
default = null
}

variable "tags" {
description = "A mapping of tags to assign to API gateway resources"
type = map(string)
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.96"
version = ">= 6.0.0"
}
}
}
1 change: 1 addition & 0 deletions wrappers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module "wrapper" {
mutual_tls_authentication = try(each.value.mutual_tls_authentication, var.defaults.mutual_tls_authentication, {})
name = try(each.value.name, var.defaults.name, "")
protocol_type = try(each.value.protocol_type, var.defaults.protocol_type, "HTTP")
region = try(each.value.region, var.defaults.region, null)
route_key = try(each.value.route_key, var.defaults.route_key, null)
route_selection_expression = try(each.value.route_selection_expression, var.defaults.route_selection_expression, null)
routes = try(each.value.routes, var.defaults.routes, {})
Expand Down
2 changes: 1 addition & 1 deletion wrappers/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.96"
version = ">= 6.0.0"
}
}
}