我正在尝试将一些外部数据从json文件加载到Terraform to merge
到appSettings map
它把它作为一个元组加载进来--无论我做什么转换,我都不能从中得到一个Map:Call to function "merge" failed: arguments must be maps or objects, got "tuple".
Json文件
[
{
"appCode": "value",
"containerName": "value",
"databaseName": "value",
"referer": "bvalue",
"shortCode": "value",
"user": "value"
},
{
"appCode": "value",
"containerName": "value",
"databaseName": "value",
"referer": "value",
"shortCode": "value",
"user": "value"
}
]
当地人:
customerSettings = jsondecode(file("vars/${var.environment}.json"))
customerAppSettingsFromJson = {
for index, externalCustomer in local.customerSettings :
externalCustomer => {
"DynamicCosmosDbSettings__CosmosHostSettings__${index}__AppCode" = "${externalCustomer.appCode}"
"DynamicCosmosDbSettings__CosmosHostSettings__${index}__ContainerName" = "${externalCustomer.containerName}"
"DynamicCosmosDbSettings__CosmosHostSettings__${index}__DatabaseName" = "${externalCustomer.databaseName}"
"DynamicCosmosDbSettings__CosmosHostSettings__${index}__Referer" = "${externalCustomer.databaseName}"
"DynamicCosmosDbSettings__CosmosHostSettings__${index}__ShortCode" = "${externalCustomer.shortCode}"
"DynamicCosmosDbSettings__CosmosHostSettings__${index}__User" = "${externalCustomer.user}"
}
}
Main.tf appSettings块,已推断出一个,一个来自vars
,另一个来自json
app_settings = merge({}, var.app_settings, local.customerAppSettingsFromJson)
1条答案
按热度按时间nfs0ujit1#
您已经非常接近解决方案,但下面是如何将对象列表转换为贴图: