地形错误此值没有任何索引

时间:2020-10-28 15:11:11

标签: terraform

我正在从tf 11升级到tf 12,我遇到了这个问题。以前在tf 11中可以使用,现在在tf 12中可以使用。有人可以帮我解决这个问题吗?

data "aws_subnet_ids" "private" {
  vpc_id = data.aws_ssm_parameter.vpc_id.value

  tags = {
    tier = "private"
  }
}

data "aws_subnet" "private" {
  count = length(data.aws_subnet_ids.private.ids)
  id    = data.aws_subnet_ids.private.ids[count.index]
}
27:   id    = data.aws_subnet_ids.private.ids[count.index]
    |----------------
    | count.index is 0
    | data.aws_subnet_ids.private.ids is set of string with 3 elements

This value does not have any indices.

1 个答案:

答案 0 :(得分:0)

此问题已解决

data "aws_subnet" "private" {
  for_each = data.aws_subnet_ids.private.ids
  id    = each.value
}