如果我的主机名是admin,环境是uat
,我想创建一个私有服务链接和私有DNS
区域,但我的if语句总是返回true。下面是一段代码
resource "your_resource_type" "example_resource" {
for_each = merge([
for i in setproduct(keys(local.static_web_app_names), keys(var.environments)) : {
join("-", i) = {
environment = i[1]
hostname = local.static_web_app_names[i[0]]
prefixes = i
}
}
]...)
private_endpoints_subnet_resource = (each.value["environment"] != "uat" && each.value["hostname"] != "admin") || each.value["environment"] != "prod" ? local.private_endpoints_subnet_resource : null
private_dns_zone_resource = (each.value["environment"] != "uat" && each.value["hostname"] != "admin") || each.value["environment"] != "prod" ? lookup(var.dns_zones_resources[each.value["environment"]][each.value["hostname"]], "private", null) : null
private_dns_zones_ids = (each.value["environment"] != "uat" && each.value["hostname"] != "admin") || each.value["environment"] != "prod" ? var.private_dns_zones_ids[each.value["environment"]] : []
}
字符串
每当我使用单个测试条件时,这都能按预期工作
resource "your_resource_type" "example_resource" {
for_each = merge([
for i in setproduct(keys(local.static_web_app_names), keys(var.environments)) : {
join("-", i) = {
environment = i[1]
hostname = local.static_web_app_names[i[0]]
prefixes = i
}
}
]...)
private_endpoints_subnet_resource = each.value["environment"] != "uat" ? local.private_endpoints_subnet_resource : null
private_dns_zone_resource = each.value["environment"] != "uat" ? lookup(var.dns_zones_resources[each.value["environment"]][each.value["hostname"]], "private", null) : null
private_dns_zones_ids = each.value["environment"] != "uat" ? var.private_dns_zones_ids[each.value["environment"]] : []
}
型
它从环境为uat
的配置中删除所有专用DNS
和专用服务链接。
1条答案
按热度按时间1l5u6lss1#
从您的语句“如果我的主机名是admin,环境是uat,我想创建一个私有服务链接和私有DNS区域”。不需要“prod”检查,您应该检查它是否是
==
,如下所示。字符串