【发布时间】:2020-07-22 12:21:12
【问题描述】:
Terraform 上的一些资源支持可选属性。我有兴趣仅在满足条件时声明和设置可选属性的值。否则,根本不要声明它。
我发现的所有建议都是基于声明属性并将其值设置为null(如果条件不满足),而不是根本不声明属性。
有没有办法让我做类似以下的事情?在伪代码中:
resource "some_resource" "this" {
name = var.name
if var.name == "some_name":
some_optional_attribute = "some_value"
else:
pass # do nothing, don't even declare the optional attribute
}
让我知道,提前谢谢!
【问题讨论】:
标签: conditional-statements terraform hcl terraform0.12+