Hi,
i'm currently experience a strange behavior with maps that contains different types of variables with Terraform 0.9.3+ (It works with versions 0.9.2 and older). If if use as single type of value in the map, it works as expected. If I mix map and list it does not work.
0.9.3+
./module/module.tf
variable "region-details" {
type = "map"
}
output "output" {
value = "${var.region-details["vpc_details"]}"
}
./root.tf
variable "multiregion-details" {
type = "map"
default = {
"us-east-1" = {
"vpc_details" = {
cidr_block = "10.0.0.0/8"
}
"subnet-details" = []
}
}
}
module "module" {
source = "./module"
region-details = "${var.multiregion-details["us-east-1"]}"
}
output "output" {
value = "${module.module.output}"
}
Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.
Map available in the module and output returned
output = [
{
cidr_block = 10.0.0.0/8
}
]
No output, no access to the map in the module
terraform applyIf i return the complete map that has been forwarded to the module i see this behaviors
<= 0.9.2
output = {
subnet-details = []
vpc_details = [map[cidr_block:10.0.0.0/8]]
}
0.9.3+
output = {
subnet-details = []
vpc_details = map[cidr_block:10.0.0.0/8]
}
Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:
Hi @DanielRis! Thanks for reporting this.
This report is confusing, since the _intent_ has always been for the configuration you shared to be considered invalid. Lots of parts of Terraform's internals assume that lists and maps always have homogeneous element types, so you were actually rather lucky that this worked without any weird crashes before. :confounded:
With that said, we know that this limitation is frustrating and are considering ways to support what you want to do here properly in future. We already have this use-case captured in a set of use-cases we've been collecting to inform a set of improvements to the language in a future version of Terraform.
Since the feature request here is already captured in #14322 I'm going to close this, but I understand that this is frustrating when this was _apparently_ working before. Unfortunately returning to the previous behavior would open us up to many crasher bugs like the one I fixed in #13343, so it wouldn't be acceptable to change this back in isolation without doing the other core improvements that need to happen first.
I do hope that we can address this in a more comprehensive way in the not-too-distant future. Thanks again for filing this and sorry there isn't an easier fix here.
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 @DanielRis! Thanks for reporting this.
This report is confusing, since the _intent_ has always been for the configuration you shared to be considered invalid. Lots of parts of Terraform's internals assume that lists and maps always have homogeneous element types, so you were actually rather lucky that this worked without any weird crashes before. :confounded:
With that said, we know that this limitation is frustrating and are considering ways to support what you want to do here properly in future. We already have this use-case captured in a set of use-cases we've been collecting to inform a set of improvements to the language in a future version of Terraform.
Since the feature request here is already captured in #14322 I'm going to close this, but I understand that this is frustrating when this was _apparently_ working before. Unfortunately returning to the previous behavior would open us up to many crasher bugs like the one I fixed in #13343, so it wouldn't be acceptable to change this back in isolation without doing the other core improvements that need to happen first.
I do hope that we can address this in a more comprehensive way in the not-too-distant future. Thanks again for filing this and sorry there isn't an easier fix here.