在 terraform HCL 中,是否可以从变量中动态引用对象的属性?
IE:
variable "attribute" {
type = "string"
}
data "terraform_remote_state" "thing" {
not_really_important
}
output "chosen" {
value = "${data.terraform_remote_state.thing.$var.attribute}"
}
更具体到我的情况,我希望使用 splat 语法来做到这一点:
variable "attribute" {
type = "string"
}
data "terraform_remote_state" "thing" {
count = 3 # really this is also a variable
not_really_important
}
output "chosen" {
value = "${data.terraform_remote_state.thing.*.$var.attribute}"
}
我已经尝试过lookup(data.terraform_remote_state.thing, var.attribute)
和(对于 splat 问题)之类的东西,lookup(element(data.terraform_remote_state.*, count.index), var.attribute)
但他们都抱怨我的属性引用不完整/格式错误。