I want to use a for_each in a kubernetes provider's kubernetes_config_map_v1's data section .. iterating over a map of filename=>content. I do not know how, as this does not work:
...
files = {for filename in fileset(path.root, "test/*json"): filename => templatefile("${path.root}/${filename}", {
prefix = local.prefix
}
)}
...
resource kubernetes_config_map_v1 xyz {
...
data = {
for_each = var.files
each.key = each.value
}
}
Error is: The "each" object can be used only in "module" or "resource" blocks, and only when the "for_each" argument is set
Any ideas?
The solution is simple, and does not need
for_each
: