diff --git a/README.md b/README.md index 2f37273..9e9ed0a 100644 --- a/README.md +++ b/README.md @@ -177,19 +177,19 @@ module "api_gateway" { | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 1.3 | -| [aws](#requirement\_aws) | >= 5.96 | +| [aws](#requirement\_aws) | >= 6.0.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 5.96 | +| [aws](#provider\_aws) | >= 6.0.0 | ## Modules | Name | Source | Version | |------|--------|---------| -| [acm](#module\_acm) | terraform-aws-modules/acm/aws | 5.0.1 | +| [acm](#module\_acm) | terraform-aws-modules/acm/aws | 6.1.0 | ## Resources @@ -239,6 +239,7 @@ module "api_gateway" { | [mutual\_tls\_authentication](#input\_mutual\_tls\_authentication) | The mutual TLS authentication configuration for the domain name | `map(string)` | `{}` | no | | [name](#input\_name) | The name of the API. Must be less than or equal to 128 characters in length | `string` | `""` | no | | [protocol\_type](#input\_protocol\_type) | The API protocol. Valid values: `HTTP`, `WEBSOCKET` | `string` | `"HTTP"` | no | +| [region](#input\_region) | The AWS region to create resources in | `string` | `null` | no | | [route\_key](#input\_route\_key) | Part of quick create. Specifies any route key. Applicable for HTTP APIs | `string` | `null` | no | | [route\_selection\_expression](#input\_route\_selection\_expression) | The route selection expression for the API. Defaults to `$request.method $request.path` | `string` | `null` | no | | [routes](#input\_routes) | Map of API gateway routes with integrations |
map(object({
# Route
authorizer_key = optional(string)
api_key_required = optional(bool)
authorization_scopes = optional(list(string), [])
authorization_type = optional(string)
authorizer_id = optional(string)
model_selection_expression = optional(string)
operation_name = optional(string)
request_models = optional(map(string), {})
request_parameter = optional(object({
request_parameter_key = optional(string)
required = optional(bool, false)
}), {})
route_response_selection_expression = optional(string)
# Route settings
data_trace_enabled = optional(bool)
detailed_metrics_enabled = optional(bool)
logging_level = optional(string)
throttling_burst_limit = optional(number)
throttling_rate_limit = optional(number)
# Stage - Route response
route_response = optional(object({
create = optional(bool, false)
model_selection_expression = optional(string)
response_models = optional(map(string))
route_response_key = optional(string, "$default")
}), {})
# Integration
integration = object({
connection_id = optional(string)
vpc_link_key = optional(string)
connection_type = optional(string)
content_handling_strategy = optional(string)
credentials_arn = optional(string)
description = optional(string)
method = optional(string)
subtype = optional(string)
type = optional(string, "AWS_PROXY")
uri = optional(string)
passthrough_behavior = optional(string)
payload_format_version = optional(string)
request_parameters = optional(map(string), {})
request_templates = optional(map(string), {})
response_parameters = optional(list(object({
mappings = map(string)
status_code = string
})))
template_selection_expression = optional(string)
timeout_milliseconds = optional(number)
tls_config = optional(object({
server_name_to_verify = optional(string)
}))
# Integration Response
response = optional(object({
content_handling_strategy = optional(string)
integration_response_key = optional(string)
response_templates = optional(map(string))
template_selection_expression = optional(string)
}), {})
})
})) | `{}` | no |
diff --git a/main.tf b/main.tf
index add0941..dd71c67 100644
--- a/main.tf
+++ b/main.tf
@@ -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,
@@ -74,6 +76,8 @@ resource "aws_apigatewayv2_authorizer" "this" {
}
name = coalesce(each.value.name, each.key)
+
+ region = var.region
}
################################################################################
@@ -106,6 +110,8 @@ resource "aws_apigatewayv2_domain_name" "this" {
}
}
+ region = var.region
+
tags = var.tags
}
@@ -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
}
################################################################################
@@ -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
@@ -175,6 +183,8 @@ module "acm" {
validation_method = "DNS"
+ region = var.region
+
tags = var.tags
}
@@ -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
}
################################################################################
@@ -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
}
################################################################################
@@ -269,6 +283,8 @@ resource "aws_apigatewayv2_integration" "this" {
lifecycle {
create_before_destroy = true
}
+
+ region = var.region
}
################################################################################
@@ -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
}
################################################################################
@@ -373,6 +391,8 @@ resource "aws_apigatewayv2_stage" "this" {
depends_on = [
aws_apigatewayv2_route.this
]
+
+ region = var.region
}
################################################################################
@@ -403,6 +423,8 @@ resource "aws_apigatewayv2_deployment" "this" {
lifecycle {
create_before_destroy = true
}
+
+ region = var.region
}
################################################################################
@@ -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
}
################################################################################
@@ -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
}
diff --git a/variables.tf b/variables.tf
index 3e2219d..a57df4d 100644
--- a/variables.tf
+++ b/variables.tf
@@ -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)
diff --git a/versions.tf b/versions.tf
index 97e1864..39270a1 100644
--- a/versions.tf
+++ b/versions.tf
@@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
- version = ">= 5.96"
+ version = ">= 6.0.0"
}
}
}
diff --git a/wrappers/main.tf b/wrappers/main.tf
index 879333a..b89ebca 100644
--- a/wrappers/main.tf
+++ b/wrappers/main.tf
@@ -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, {})
diff --git a/wrappers/versions.tf b/wrappers/versions.tf
index 97e1864..39270a1 100644
--- a/wrappers/versions.tf
+++ b/wrappers/versions.tf
@@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
- version = ">= 5.96"
+ version = ">= 6.0.0"
}
}
}