github cloudposse/terraform-aws-alb v2.1.0

one day ago
fix: listener default action variable object block [HOTFIX REQUIRED!] @oycyc (#190) ## what

Removes the default object block and changes it to null, making it consistent with the other default actions. The original mindset of having it was to default to HTTP_301 since it's a required attribute, but it doesn't matter because it is not optional() in the Terraform.

why

As described by @mschfh

this adds a redirect by default, as the default for the variable is an object, not null.

terraform-aws-alb/main.tf

Lines 231 to 232 in cb8fa65

dynamic "redirect" {
for_each = var.listener_https_redirect != null ? [var.listener_https_redirect] : []

terraform-aws-alb/variables.tf

Lines 292 to 311 in cb8fa65

variable "listener_https_redirect" {
description = "Have the HTTPS listener return a redirect response for the default action."
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lb_listener#status_code-2
type = object({
host = optional(string)
path = optional(string)
port = optional(string)
protocol = optional(string)
query = optional(string)
status_code = string
})
default = {
host = null
path = null
port = null
protocol = null
query = null
status_code = "HTTP_301"
}
}

Plan:

      ~ default_action {
          ~ type             = "forward" -> "redirect"
            # (2 unchanged attributes hidden)

          + redirect {
              + host        = "#{host}"
              + path        = "/#{path}"
              + port        = "#{port}"
              + protocol    = "#{protocol}"
              + query       = "#{query}"
              + status_code = "HTTP_301"
            }
        }

Explicitly passing listener_https_redirect = null to the module does prevent this change, please update the default or adjust the for_each.

image

references

Comment referencing this issue
#187 (comment)

Don't miss a new terraform-aws-alb release

NewReleases is sending notifications on new releases.