我正在尝试使用对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,但出现以下错误:
这是我的实现方式:
locals {
nlb_interface_ids = try(flatten(["${data.aws_network_interfaces.this.ids}"]), [])
}
我正在运行terraform v0.12.18。有人可以帮忙吗。
try
函数已在版本0.12.20中添加。您需要从0.12.18更新到至少该版本才能访问try
功能。请注意相关的release notes。