-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panic trying to use nested maps in 0.7_rc2 #7637
Comments
Prior to this crash, the config file looked like this:
and gave this error:
|
Thanks for the report, @pccowboy! I can reproduce this (though slightly differently) with the |
Hi @pccowboy! I'll address the panic soon, but the correct way to do this is as follows: variable "db_replica_alarms_totals" {
type = "map"
default = {
count = "2"
take = "2"
}
}
variable "db_replica_alarms_settings" {
type = "list"
default = [
{
"0" = "a"
"1" = "b"
"desc" = "one desc"
},
{
"0" = "c"
"1" = "d"
"desc" = "two desc"
},
]
}
resource "aws_cloudwatch_metric_alarm" "replica_alarms" {
count = "${var.db_replica_alarms_totals["count"]}"
alarm_description = "${lookup(var.db_replica_alarms_settings[count.index], "desc")}"
} |
@jen20 Thanks for the pointer, I am still wrapping my head around HCL and terraform. I had similar code working in 0.6.16, but in that version each map in db_replica_alarms_settings was a separate variable - one for description, one for action, etc. My old Perl habits were hoping to intermix objects in 0.7 a bit more than I maybe should hope for. Looking forward to 0.7 GA, thanks again! |
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. |
Terraform Version
dswift@bebox terraform (chore-121334261)*$ terraform --version
Terraform v0.7.0-rc2 (46a0709)
Affected Resource(s)
N/A
Terraform Configuration Files
Debug Output
https://gist.github.com/pccowboy/c9d4e9f94ec404a718f745b2053351a5
Panic Output
https://gist.github.com/pccowboy/c9d4e9f94ec404a718f745b2053351a5
Expected Behavior
Trying to figure out how to access a variable in a nested map. I expected an error, due to the aws_cloudwatch_metric_alarm resource being incomplete.
Actual Behavior
crash
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform plan t
Important Factoids
N/A
References
N/A
The text was updated successfully, but these errors were encountered: