Terraform: Terraform 0.12.26 crash on list with mixed maps: list(map(any))

Created on 30 May 2020  ยท  3Comments  ยท  Source: hashicorp/terraform

Terraform Version

Terraform v0.12.26

Terraform Configuration Files

variable "mixedmap" {
  type = list(map(any))
  default = [
    {
      string_value = "string"
    },
    {
      list_value = ["list"]
    },
  ]
}

Debug Output


https://gist.github.com/brnl/92bd2ccc2e43030392645d7f3a4b343b#file-terraform-trace-log

Crash Output


https://gist.github.com/brnl/92bd2ccc2e43030392645d7f3a4b343b#file-crash-log

Expected Behavior


I expected (or hoped) to get a list with two maps. One with string values and one with list values. Something like this:

Outputs:

mixedmap = [
  {
    "string_value" = "string"
  },
  {
    "list_value" = [
      "list",
    ]
  },
]

_Or_ I expected an error that mixed types are not allowed.

Actual Behavior


Terraform crashed.

Steps to Reproduce


On the HCL above, just a terraform apply is enough to crash it.

Additional Context

Creating the variable without a type constraint works without a problem:

variable "mixedmap" {
  # type = list(map(any))
  default = [
    {
      string_value = "string"
    },
    {
      list_value = ["list"]
    },
  ]
}

output "mixedmap" {
  value = var.mixedmap
}

Produces:

Outputs:

mixedmap = [
  {
    "string_value" = "string"
  },
  {
    "list_value" = [
      "list",
    ]
  },
]          

And, constraining to just a list, doesn't crash but does give an error:

variable "mixedmap" {
  type = list(any)
  default = [
    {
      string_value = "string"
    },
    {
      list_value = ["list"]
    },
  ]
}
Error: Invalid default value for variable

  on mapslists.tf line 30, in variable "mixedmap":
  30:   default = [
  31:     {
  32:       string_value = "string"
  33:     },
  34:     {
  35:       list_value = ["list"]
  36:     },
  37:   ]

This default value is not compatible with the variable's type constraint: all
list elements must have the same type.

References

bug crash v0.12

Most helpful comment

Hi! I'm pretty sure this is the same as https://github.com/hashicorp/terraform/issues/21588#issuecomment-592149310 which is fixed in 0.13. We'll be releasing a beta of 0.13 on Wednesday next week, so you'll be able to confirm this fairly soon. This same issue has been reported a few times, and your case looks identical to the others. I really appreciate you reporting this. I'm going to close it because I'm pretty sure it's the same as the other cases, but if you look and don't think it is, or try out the 0.13 beta and don't see this fixed, feel free to let me know either here or at [email protected]. Have a nice weekend!

All 3 comments

Hi! I'm pretty sure this is the same as https://github.com/hashicorp/terraform/issues/21588#issuecomment-592149310 which is fixed in 0.13. We'll be releasing a beta of 0.13 on Wednesday next week, so you'll be able to confirm this fairly soon. This same issue has been reported a few times, and your case looks identical to the others. I really appreciate you reporting this. I'm going to close it because I'm pretty sure it's the same as the other cases, but if you look and don't think it is, or try out the 0.13 beta and don't see this fixed, feel free to let me know either here or at [email protected]. Have a nice weekend!

I think you're right, @danieldreier. I didn't find this while searching. Sorry for double posting. :smiley:

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Seraf picture Seraf  ยท  3Comments

rkulagowski picture rkulagowski  ยท  3Comments

franklinwise picture franklinwise  ยท  3Comments

ketzacoatl picture ketzacoatl  ยท  3Comments

shanmugakarna picture shanmugakarna  ยท  3Comments