我想做smth非常基本的这是我的变量文件
test = {
t1 = {
top = [
{
port = "12"
name = "port12"
},
{
port = "123"
name = "port123"
}
]
},
t2 = {
top = [
{
port = "12"
name = "port12"
},
{
port = "123"
name = "port123"
}
]
}
}
resource "azurerm_lb_nat_rule" "nat" {
for_each = var.test
resource_group_name = var.rg.name
loadbalancer_id = elb.id
name = "ELB-XX"
protocol = "Tcp"
frontend_port = each.value.top.port
backend_port = each.value.top.port
frontend_ip_configuration_name = pip.id
}
我想要:
- 名称如ELB-T1-port 12、ELB-T2-port 12、ELB-T1-port 123和ELB-T2-port 123
- 检索frontend_port和backend_port的端口
我可以改变变量列表
1条答案
按热度按时间csga3l581#
基于此配置,您可以创建azurerm_lb_nat_rule资源,如下所示:
您可以阅读更多:The for_each Meta-Argument