在我的terragrunt.hcl
文件中,我将几个变量传递给一个模块 - 其中一个是 map 和 list
terraform {
source = "git@github.com:<my_account>/infrastructure-modules.git//iam?ref=v.0.0.9"
}
include {
path = find_in_parent_folders()
}
inputs = {
var_1 = "string"
var_2 = {
object1 = {
val1 : "a",
val2 : "b"
},
object2 = {
val3 : "c",
val4 : "d"
}
}
但是当我将它传递给一个模块时
resource "google_project_iam_binding" "members" {
for_each = var.var2
project = var.project_name
role = "projects/${var.project_name}/roles/${each.key}"
members = each.value
}
它不理解它并将其视为一个字符串
Error: Invalid for_each argument
on main.tf line 34, in resource "google_project_iam_binding" "members":
34: for_each = var.var2
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
string.
有人对可能是什么问题有任何想法吗?