如果我有這樣的 json 檔案:
{
"allMyTags": {
"owner": "john",
"department": "HR",
"city": "New York"
}
}
我的 AWS 提供商 terraform main.tf 看起來像這樣:
resource "aws_vpc" "example" {
# ... other configuration ...
tags = {
owner = "john"
}
}
如何用外部 json 檔案替換 main.tf 的標簽部分中的所有內容。json 檔案比我放在那里的要長得多,我只是不想在 main.tf 的標簽部分手動輸入 20 個值。有沒有辦法通過json檔案“回圈”并添加它?感謝您的任何幫助,您可以提供。
uj5u.com熱心網友回復:
假設您的 json 已經加載到 TF 中,您可以這樣做:
resource "aws_vpc" "example" {
# ... other configuration ...
tags = jsondecode(local.myjson["allMyTags"])
}
local.myjson加載到 TF 的 json在哪里。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/476139.html
標籤:json 亚马逊网络服务 地形 terraform-provider-aws
