运行时terraform plan或terraform apply使用提供给for_each错误的列表时,说
Error: Invalid for_each argument
on main.tf line 2, in resource "aws_ssm_parameter" "foo":
2: for_each = ["a", "b"]
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.
Run Code Online (Sandbox Code Playgroud)
重现此错误的最小示例如下:
resource "aws_ssm_parameter" "foo" {
for_each = ["a", "b"]
name = "foo-${each.value}"
type = "String"
value = "bar-${each.value}"
}
Run Code Online (Sandbox Code Playgroud)