未找到Terraform try()函数

问题描述 投票:1回答:1

我正在尝试使用对aws_network_interfaces地形资源的数据查找来查找NLB的ENI。如果可以找到任何ENI,这就像一个超级按钮,但是当您执行第一个计划并且AWS账户仍为空时,资源会引发错误。

这里是查找:

data "aws_network_interfaces" "this" {

  filter {
    name   = "description"
    values = ["ELB net/${aws_lb.proxy.name}/*"]
  }
  filter {
    name   = "vpc-id"
    values = ["${var.vpc_id}"]
  }
  filter {
    name   = "status"
    values = ["in-use"]
  }
  filter {
    name   = "attachment.status"
    values = ["attached"]
  }
}

为了解决这个问题,我想使用地形try() function,但出现以下错误:

enter image description here

这是我的实现方式:

locals {
  nlb_interface_ids = try(flatten(["${data.aws_network_interfaces.this.ids}"]), [])
}

我正在运行terraform v0.12.18。有人可以帮忙吗。

amazon-web-services try-catch terraform terraform-provider-aws
1个回答
2
投票

try函数已在版本0.12.20中添加。您需要从0.12.18更新到至少该版本才能访问try功能。请注意相关的release notes

© www.soinside.com 2019 - 2024. All rights reserved.