数据中的地形输出= <<EOF



鉴于我有

data_json = <<EOT
{
"policies": ["${local.test2}"],
"password": "${local.test3}"
}
EOT

我可以使用

从它输出所有值
output "test1" {
value = values(jsondecode(local.data_json))
}
Changes to Outputs:
+ ids1 = [
+ "bbb",
+ [
+ "aaaa",
],
]

但是我怎么能从中只得到密码值呢?

我得到

│ Error: Unsupported attribute
│
│   on main.tf line 63, in output "ids1":
│   63:     value = values(jsondecode(local.data_json.password))
│     ├────────────────
│     │ local.data_json is "{n  "policies": ["aaaa"],n  "password": "bbb"n}n"
│
│ Can't access attributes on a primitive-typed value (string).

感谢

要获得password,您可以这样做:

output "test1" {
#sensitive = true # <-- this could be good to uncomment for security
value = jsondecode(local.data_json)["password"]
}

相关内容

最新更新