小编Fal*_*zky的帖子

Terraform 因无效的 for_each 参数而失败/给定的“for_each”参数值不合适

运行时terraform planterraform 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)

foreach amazon-web-services terraform

12
推荐指数
1
解决办法
8526
查看次数

标签 统计

amazon-web-services ×1

foreach ×1

terraform ×1