将terraform升级到v0.11.7后执行terraform计划时出错,请使用splat语法访问已定义的属性

时间:2018-05-02 20:18:16

标签: amazon-web-services terraform terraform-provider-aws

升级我的terraform后,我的命名模块坏了,我不知道如何修复命名模块。

data "aws_region" "current" {
  current = true
}
 
data "aws_vpc" "vpc" {
  count = "${var.has_vpc_id == 0 ? 0 : 1}"
  id    = "${var.vpc_id}"
}
 
output "iam" {
  value = "${
      join("-", list(
        join("", list(
          substr(element(split("-", data.aws_region.current.name), 0), 0, 2),
          substr(element(split("-", data.aws_region.current.name), 1), 0, 1),
          substr(element(split("-", data.aws_region.current.name), 2), 0, 1),
        )),
        var.friendly_name
      ))}"
}
 
output "vpc" {
  value = "${
    map(
      "none", join("-", list(
        join("", list(
          substr(element(split("-", data.aws_region.current.name), 0), 0, 2),
          substr(element(split("-", data.aws_region.current.name), 1), 0, 1),
          substr(element(split("-", data.aws_region.current.name), 2), 0, 1),
        )),
        element(split("-", lookup(data.aws_vpc.vpc.*.tags, "Name")), var.vpc-name-offset),
        lookup(var.environments, var.environment),
        var.friendly_name
      )),
      "a", join("-", list(
        join("", list(
          substr(element(split("-", data.aws_region.current.name), 0), 0, 2),
          substr(element(split("-", data.aws_region.current.name), 1), 0, 1),
          substr(element(split("-", data.aws_region.current.name), 2), 0, 1),
          "a"
        )),
        element(split("-", lookup(data.aws_vpc.vpc.*.tags, "Name")), var.vpc-name-offset),
        lookup(var.environments, var.environment),
        var.friendly_name
      )),
      "b", join("-", list(
        join("", list(
          substr(element(split("-", data.aws_region.current.name), 0), 0, 2),
          substr(element(split("-", data.aws_region.current.name), 1), 0, 1),
          substr(element(split("-", data.aws_region.current.name), 2), 0, 1),
          "b"
        )),
        element(split("-", lookup(data.aws_vpc.vpc.*.tags, "Name")), var.vpc-name-offset),
        lookup(var.environments, var.environment),
        var.friendly_name
      )),
      "c", join("-", list(
        join("", list(
          substr(element(split("-", data.aws_region.current.name), 0), 0, 2),
          substr(element(split("-", data.aws_region.current.name), 1), 0, 1),
          substr(element(split("-", data.aws_region.current.name), 2), 0, 1),
          "c"
        )),
        element(split("-", lookup(data.aws_vpc.vpc.*.tags, "Name")), var.vpc-name-offset),
        lookup(var.environments, var.environment),
        var.friendly_name
      )),
      "d", join("-", list(
        join("", list(
          substr(element(split("-", data.aws_region.current.name), 0), 0, 2),
          substr(element(split("-", data.aws_region.current.name), 1), 0, 1),
          substr(element(split("-", data.aws_region.current.name), 2), 0, 1),
          "d"
        )),
        element(split("-", lookup(data.aws_vpc.vpc.*.tags, "Name")), var.vpc-name-offset),
        lookup(var.environments, var.environment),
        var.friendly_name
      ))
    )
  }"
}
 
output "no_vpc" {
  value = "${
      join("-", list(
        join("", list(
          substr(element(split("-", data.aws_region.current.name), 0), 0, 2),
          substr(element(split("-", data.aws_region.current.name), 1), 0, 1),
          substr(element(split("-", data.aws_region.current.name), 2), 0, 1),
        )),
        lookup(var.environments, var.environment),
        var.friendly_name
      ))}"
}
 

我得到的错误如下: 警告:输出“vpc”:必须使用splat语法访问data.aws_vpc.vpc属性“tags”,因为它有“count”设置;使用data.aws_vpc。*。标签获取所有实例的属性列表

0 个答案:

没有答案