diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b567c52..0983882 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/antonbabenko/pre-commit-terraform - rev: v1.92.0 + rev: v1.92.1 hooks: - id: terraform_fmt - id: terraform_wrapper_module_for_each diff --git a/README.md b/README.md index 77a79ef..76df66a 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ module "api_gateway" { | [api\_version](#input\_api\_version) | A version identifier for the API. Must be between 1 and 64 characters in length | `string` | `null` | no | | [authorizers](#input\_authorizers) | Map of API gateway authorizers to create |
map(object({
authorizer_credentials_arn = optional(string)
authorizer_payload_format_version = optional(string)
authorizer_result_ttl_in_seconds = optional(number)
authorizer_type = optional(string, "REQUEST")
authorizer_uri = optional(string)
enable_simple_responses = optional(bool)
identity_sources = optional(list(string))
jwt_configuration = optional(object({
audience = optional(list(string))
issuer = optional(string)
}))
name = optional(string)
}))
| `{}` | no | | [body](#input\_body) | An OpenAPI specification that defines the set of routes and integrations to create as part of the HTTP APIs. Supported only for HTTP APIs | `string` | `null` | no | -| [cors\_configuration](#input\_cors\_configuration) | The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs |
object({
allow_credentials = optional(bool)
allow_headers = optional(list(string))
allow_methods = optional(list(string))
allow_origins = optional(list(string))
expose_headers = optional(list(string), [])
max_age = optional(number)
})
| `{}` | no | +| [cors\_configuration](#input\_cors\_configuration) | The cross-origin resource sharing (CORS) configuration. Applicable for HTTP APIs |
object({
allow_credentials = optional(bool)
allow_headers = optional(list(string))
allow_methods = optional(list(string))
allow_origins = optional(list(string))
expose_headers = optional(list(string), [])
max_age = optional(number)
})
| `null` | no | | [create](#input\_create) | Controls if resources should be created | `bool` | `true` | no | | [create\_certificate](#input\_create\_certificate) | Whether to create a certificate for the domain | `bool` | `true` | no | | [create\_domain\_name](#input\_create\_domain\_name) | Whether to create API domain name resource | `bool` | `true` | no | diff --git a/main.tf b/main.tf index ae05c10..4155162 100644 --- a/main.tf +++ b/main.tf @@ -16,7 +16,7 @@ resource "aws_apigatewayv2_api" "this" { body = local.is_http ? var.body : null dynamic "cors_configuration" { - for_each = local.is_http && length(var.cors_configuration) > 0 ? [var.cors_configuration] : [] + for_each = local.is_http && var.cors_configuration != null ? [var.cors_configuration] : [] content { allow_credentials = cors_configuration.value.allow_credentials diff --git a/variables.tf b/variables.tf index 841c070..d9d6b11 100644 --- a/variables.tf +++ b/variables.tf @@ -30,7 +30,7 @@ variable "cors_configuration" { expose_headers = optional(list(string), []) max_age = optional(number) }) - default = {} + default = null } variable "credentials_arn" { diff --git a/wrappers/main.tf b/wrappers/main.tf index 9111439..a445b7a 100644 --- a/wrappers/main.tf +++ b/wrappers/main.tf @@ -8,7 +8,7 @@ module "wrapper" { api_version = try(each.value.api_version, var.defaults.api_version, null) authorizers = try(each.value.authorizers, var.defaults.authorizers, {}) body = try(each.value.body, var.defaults.body, null) - cors_configuration = try(each.value.cors_configuration, var.defaults.cors_configuration, {}) + cors_configuration = try(each.value.cors_configuration, var.defaults.cors_configuration, null) create = try(each.value.create, var.defaults.create, true) create_certificate = try(each.value.create_certificate, var.defaults.create_certificate, true) create_domain_name = try(each.value.create_domain_name, var.defaults.create_domain_name, true)