Terraform v0.12.26
variable "mixedmap" {
type = list(map(any))
default = [
{
string_value = "string"
},
{
list_value = ["list"]
},
]
}
https://gist.github.com/brnl/92bd2ccc2e43030392645d7f3a4b343b#file-terraform-trace-log
https://gist.github.com/brnl/92bd2ccc2e43030392645d7f3a4b343b#file-crash-log
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.
Terraform crashed.
On the HCL above, just a terraform apply is enough to crash it.
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.
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.
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!