【发布时间】:2020-12-01 21:26:29
【问题描述】:
我正在使用 tfe 提供程序进行 terraform 工作区自动化,并希望使用以下数据结构中的 custom_tags 创建一个 terraform HCL 变量作为地图。
workspaces = {
"PROD" = {
"custom_tags" = {
"Application" = "demo"
"EnvironmentType" = "prod"
"NamePrefix" = "sof"
"ProductType" = "terraform"
}
"env_variables" = {}
"id" = "alfsdfksf"
"name" = "PROD"
"repo" = "github/something"
"tf_variables" = {}
}
"UAT" = {
"custom_tags" = {
"Application" = "demo"
"EnvironmentType" = "uat"
"NamePrefix" = "sof"
"ProductType" = "terraform"
}
"env_variables" = {}
"id" = "ws-k7KWYfsdfsdf"
"name" = "UAT"
"repo" = "github/otherthing"
"tf_variables" = {}
}
}
这是我的资源块
resource "tfe_variable" "terraform_hcl_variables" {
for_each = { for w in local.workspaces : w.name => w }
key = "custom_tags"
value = each.value.custom_tags
category = "terraform"
hcl = true
sensitive = false
workspace_id = tfe_workspace.main[each.key].id
}
而且,我收到了这个错误。感谢您提供任何帮助来解决此问题。
**each.value.custom_tags is object with 4 attributes
Inappropriate value for attribute "value": string required.**
预期结果
custom_tags 应创建为 HCL 变量
custom_tags =
{
"Application" = "demo"
"EnvironmentType" = "prod"
"NamePrefix" = "sof"
"ProductType" = "terraform"
}
【问题讨论】:
标签: terraform