【发布时间】:2026-01-14 11:45:02
【问题描述】:
我打算通过向 Terraform 提供 Azure ARM 模板来使用 Terraform 配置 Azure AD 域服务,这是因为 Terrafrom 不支持原生配置 Azure AD 域服务。
我已经导出了 ARM 模板及其参数,其中一个参数称为 "notificationSettings",它是 Object 类型,如下所示:
"notificationSettings": {
"value": {
"notifyGlobalAdmins": "Enabled",
"notifyDcAdmins": "Enabled",
"additionalRecipients": []
}
}
其他参数都是strings,我可以毫无问题地传递它们,例如:
"apiVersion" = "2017-06-01"
我已尝试将此对象传递给如下参数:
"notificationSettings" = [{
"notifyGlobalAdmins" = "Enabled"
"notifyDcAdmins" ="Enabled"
"additionalRecipients" = []
}]
但是,当我执行terrafrom apply 时,terrafrom 抱怨说:
属性“参数”的值不合适:元素 “notificationSettings”:需要字符串。
如何将 Object 的参数类型传递给template body?
我还尝试使用parameters_body 选项将整个 ARM json 参数作为文件提供给 terrafrom,如下所示:
parameters_body = "${file("${path.module}/temp/params.json")}"
但是,执行 terrafrom 脚本时出现以下错误:
请求内容无效,无法反序列化:'Error 转换价值 "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#" 输入 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Data.Definitions.DeploymentParameterDefinition'。 路径 'properties.parameters.$schema',第 1 行,位置 2952。'。
下面是params.json 文件:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"apiVersion": {
"value": "2017-06-01"
},
"sku": {
"value": "Standard"
"location": {
"value": "westus"
},
"notificationSettings": {
"value": {
"notifyGlobalAdmins": "Enabled",
"notifyDcAdmins": "Enabled",
"additionalRecipients": []
}
},
"subnetName": {
"value": "xxxx"
},
"vnetName": {
"value": "xxxx"
},
"vnetAddressPrefixes": {
"value": [
"10.0.1.0/24"
]
},
"subnetAddressPrefix": {
"value": "10.0.1.0/24"
},
"nsgName": {
"value": "xxxxx"
}
}
}
【问题讨论】:
标签: terraform terraform-provider-azure