【发布时间】:2022-01-18 21:57:29
【问题描述】:
我正在尝试将列表映射传递给模板化的 yaml 文件,然后引用该列表的特定元素。我知道这利用了遗留的template_file 类型,但我仍然很好奇为什么我正在做的事情没有渲染。当我通过本地测试时,同样的逻辑也能正常工作。
变量:
variable "my_recipients" {
description = "Recipients To Identify"
type = map(list(string))
default = {
abcd = [
"myrecipientA"
],
zyx = [
"myrecipientB"
]
}
}
template_file sn-p:
data "template_file" "policies" {
template = myfile.yaml
recipients_all = jsonencode(var.my_recipients)
}
yaml 文件 sn-p:
to:
- ${jsondecode({recipients_all})["zyx"]} #Goal is to get the value myrecipientB
我希望得到 myrecipientB 的值,但我得到了错误:
Missing key/value separator; Expected an equals sign ("=") to mark the beginning of the attribute value.
任何建议都将不胜感激,因为这似乎是一个应该可行的简单想法,但我不确定我误解了什么。
【问题讨论】:
-
我认为您遇到的问题与一些关于每个函数和模板的预期内容的小细节有关。您希望在最后看到什么,映射到“xyz”([“myrecipientB”])的完整元素列表?“xyz”(“myrecipientB”)列表中的第一个元素?
标签: terraform