Skip to content

[Bug] ordered_cache_behavior not present throwing an error #178

@eylon-commit

Description

@eylon-commit

Description

 Error: Invalid function argument
  │
  │   on ..\main.tf line 538, in locals:
  │  538:   cache_behaviors = concat([var.default_cache_behavior], var.ordered_cache_behavior)
  │     ├────────────────
  │     │ while calling concat(seqs...)
  │     │ var.ordered_cache_behavior is null
  │
  │ Invalid value for "seqs" parameter: argument must not be null.

This error only happens in version 6.0.0; in version 5.2.0, everything works.
I think this is because the "ordered_cache_behavior" is defaulted to "null" and concat expects only lists.

Version 5.2.0 item in wrapper:
ordered_cache_behavior = try(each.value.ordered_cache_behavior, var.defaults.ordered_cache_behavior, [])

Version 6.0.0 item in wrapper:
ordered_cache_behavior = try(each.value.ordered_cache_behavior, var.defaults.ordered_cache_behavior, null)

So the solution is either to return an empty list as before or to use a different Terraform function.

Versions

  • Module version: 6.0.0

  • Terraform version:
    v1.13.5

  • Provider version(s):
    6.23.0

Reproduction Code [Required]

inputs = {
  defaults = {
    create = true
  }

  items = {
    xxxxx-builds = {
      create_origin_access_control = true # This is removed in version 6.0.0
      default_root_object          = "index.html"
      comment                      = "xxxxxx"
      create_origin_s3_bucket      = true
      origin_s3_bucket             = "xxxxxxx-${local.aws_region}-xxxxx"
      origin_access_control = {
        s3-origin-xxxx = {
          description      = "CloudFront access to S3"
          origin_type      = "s3"
          signing_behavior = "always"
          signing_protocol = "sigv4"
        }
      }

      origin = {
        s3-origin-xxxxx = {
          domain_name           = xxxxxxx-${local.aws_region}-builds.s3.${local.aws_region}.amazonaws.com"
          origin_access_control = "s3-origin-xxxxxxx"
        }
      }

      default_cache_behavior = {
        target_origin_id       = "s3-origin-xxxxxxx"
        viewer_protocol_policy = "redirect-to-https"

        allowed_methods      = ["GET", "HEAD", "OPTIONS"]
        cached_methods       = ["GET", "HEAD"]
        compress             = true
        query_string         = true
        cache_policy_id      = "658327ea-f89d-4fab-a63d-7e88639e58f6"
        use_forwarded_values = false
      }

      custom_error_response = [
        {
          error_code            = 403
          response_code         = 200
          response_page_path    = "/index.html"
          error_caching_min_ttl = 10
        },
        {
          error_code            = 404
          response_code         = 200
          response_page_path    = "/index.html"
          error_caching_min_ttl = 10
        }
      ]
    }
  }
}

Terminal Output Screenshot(s)

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions