Terraform The given expressions are tuple and object, respectively

Viewed 13

I am new to terraform can some one point me what is the issue here ??

Error: Inconsistent conditional result types
│
│   on .terraform\modules\frontend_website.cloudfront\main.tf line 17, in resource "aws_cloudfront_distribution" "www_distribution":
│   17:     for_each = length(var.custom_error_response) == 0 ? [] : var.custom_error_response
│     ├────────────────
│     │ var.custom_error_response is object with 4 attributes
│
│ The true and false result expressions must have consistent types. The given
│ expressions are tuple and object, respectively.
dynamic "custom_error_response" {
    for_each = length(var.custom_error_response) == 0 ? [] : var.custom_error_response

    content {
      error_caching_min_ttl = lookup(custom_error_response.value, "error_caching_min_ttl", "3000")
      error_code            = lookup(custom_error_response.value, "error_code", "404")
      response_code         = lookup(custom_error_response.value, "response_code", "200")
      response_page_path    = lookup(custom_error_response.value, "response_page_path", "/index.html")
    }
  } 
1 Answers

Thanks Mark for the reply , i fixed it instead of object i put a square bracket and made it is array of object , that fixed it , thanks

Related