Terraform v0.12.6
+ provider.null v2.1.2
locals {
i = ["t", "g", "f"]
}
data "null_data_source" "test" {
for_each = local.i
inputs = {
value = each.value
}
}
https://gist.github.com/dpiddockcmp/25d0622a732b41ae704e2bcd9132f895
Either:
for_each not supporting listsCrash. panic: not a string
terraform initterraform planThanks for the bug report. I'm pleased to say that this is fixed by https://github.com/hashicorp/terraform/pull/22279, and the new error you'll get is:
$ terraform plan
Error: Invalid for_each argument
on main.tf line 6, in data "null_data_source" "test":
6: for_each = local.i
The given "for_each" argument value is unsuitable: the "for_each" argument
must be a map, or set of strings, and you have provided a value of type tuple.
This fix will be deployed in Terraform v0.12.7.
Not sure why this issue is closed. #22279 doesn't actually fix the problem of using a list with for_each, it only turns it into an error.
for_each only works with sets and maps/objects. You need to turn your list into a set using toset() function.
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.