-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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 when using for and for_each iterating through list(map(string)) #22347
Comments
This looks like the same issue as #22305. |
@wata727 is correct! This is fixed in master and will be released in 0.12.7 of Terraform (and I'll leave this open until that is out, and have self-assigned to do so). To work around this, ensure that you are passing a set and not a list (which Terraform is interpreting as a tuple) to Thank you for the report! |
Terraform 0.12.7 (with this fix) is now released! https://github.com/hashicorp/terraform/blob/v0.12.7/CHANGELOG.md |
@pselle I have a very similar example to @jvelasquezjs (with the
Can we not pass in a for_each = toset([for r in var.records_list : {
r_name = lookup(r, "name", null)
r_type = lookup(r, "type", "CNAME")
r_ttl = lookup(r, "ttl", 60)
r_record = lookup(r, "record", null)
}]) But I get the same error as above. And also this... for_each = toset(var.records_list) But I get this...
|
Actually I found a solution for my above comment here: #22610 (comment). However, I'm not sure why |
@sc250024 can you post the working example. Messing around with different options is not ver clear to me which code change worked for the original example. |
@t5unamie Yep. I was using it to make a module for GitLab repositories. vars.tf variable "branch_protection_map" {
default = {
master = {
merge_access_level = "developer"
push_access_level = "maintainer"
}
}
description = "Map of branch / access-level mappings to protected branches."
type = map(map(string))
} main.tf resource "gitlab_branch_protection" "this" {
for_each = var.branch_protection_map
project = gitlab_project.this.id
branch = each.key
merge_access_level = lookup(each.value, "merge_access_level", "developer")
push_access_level = lookup(each.value, "push_access_level", "maintainer")
} I guess Terraform needs a |
@sc250024 thanks |
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
Terraform Configuration Files
my module in `./module
using the module
Debug Output
Crash Output
https://gist.github.com/jvelasquezjs/262fdb16e7d18e1272c424e8d08fa18c
Expected Behavior
Not to panic...
Actual Behavior
Panic due to string not expected
Steps to Reproduce
terraform init
AWS_DEFAULT_REGION=eu-west-1 terraform plan
Additional Context
References
The text was updated successfully, but these errors were encountered: