我需要一些帮助,我正在尝试为azure ACI容器实例编写一个模块。我发现dns_name_label和network_profile_id这两个属性是互斥的。如果我将ip_address_type设置为public,我想使用dns_name_label,但network_profile_id不能使用相同的脚本,反之亦然;如果我将ip_address_type设置为私有,我必须定义network_profile_id,但dns_name_label不能使用脚本
如果同时包含dns_name_label和network_profile_id,在ip_address_type上会怎样呢?
resource "azurerm_container_group" "this" {
name = var.name
location = var.location
resource_group_name = var.resource_group_name
ip_address_type = var.ip_address_type
dns_name_label = var.ip_address_type =="Public"&&length(var.dns_name_label)> 0 ? var.dns_name_label :""
os_type = var.os_type
restart_policy = var.restart_policy
network_profile_id = var.ip_address_type == "Private" ? azurerm_network_profile.this[0].id : ""
}注意上面的代码不起作用,我得到了错误
"network_profile_id": conflicts with dns_name_label发布于 2021-08-23 04:24:53
您可以使用null而不是"",如果将null设置为其值,则将从资源中删除该属性:
resource "azurerm_container_group" "this" {
name = var.name
location = var.location
resource_group_name = var.resource_group_name
ip_address_type = var.ip_address_type
dns_name_label = var.ip_address_type =="Public"&&length(var.dns_name_label)> 0 ? var.dns_name_label : null
os_type = var.os_type
restart_policy = var.restart_policy
network_profile_id = var.ip_address_type == "Private" ? azurerm_network_profile.this[0].id : null
}https://stackoverflow.com/questions/68887263
复制相似问题