【问题标题】:get specific output from terraform rt 53 resolver从 terraform rt 53 解析器获取特定输出
【发布时间】:2021-06-11 06:15:36
【问题描述】:

我有这个输出

ip_adresses = [
  [
    {
      "ip" = "192.168.1.1"
      "ip_id" = "rni-297efwf83340689"
      "subnet_id" = "subnet-123456789"
    },
    {
      "ip" = "192.168.1.2"
      "ip_id" = "rni-40b04503a"
      "subnet_id" = "subnet-123465798"
    },
  ],
]

这是我的输出语句

  description = "Resolver IP addresses"
  value = aws_route53_resolver_endpoint.whatever[*].ip_address.ip

}

如何只获取 IP 而不是全部?

【问题讨论】:

    标签: terraform terraform0.12+


    【解决方案1】:

    用于输出的 terraform 手册页,“在自动化中使用”部分:

    https://www.terraform.io/docs/cli/commands/output.html

    对于在shell中直接使用字符串值的常见情况 脚本,您可以使用 -raw 代替,它将直接打印字符串 没有额外的转义或空格。

    所以我认为你在做的是:

    terraform output aws_route53_resolver_endpoint.whatever[*].ip_address.ip
    //outputs:
    ip = [192.168.1.1]
    

    所以ip文本,等号和方括号是不需要的弹片。

    所以如果你添加参数-raw,我想这就是你想要的:

    terraform output -raw aws_route53_resolver_endpoint.whatever[*].ip_address.ip
    //outputs:
    192.168.1.1
    

    只有ip,其他的都没有了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-08
      • 1970-01-01
      • 2019-12-05
      • 2014-08-29
      • 1970-01-01
      • 2015-09-16
      • 2020-01-21
      • 1970-01-01
      相关资源
      最近更新 更多