I’m trying to create an Azure Load balaner. I have a use case where I want multiple front end ports for same backend port
example:
fronted port 8443 → backend port 8443
fronted port 443 → backend port 8443
The LB definition is in a map
variable "lb_details" {
type = map
default = {
rule_8443 = {
fe_port = "8443"
be_port = "8443"
proto = "Tcp"
name = "rule-8443"
probename = "probe-8443"
load_distribution = "SourceIPProtocol"
},
rule_443 = {
fe_port = "443"
be_port = "8443"
proto = "Tcp"
name = "rule-443"
probename = "probe-8443"
load_distribution = "SourceIPProtocol"
},
here is my probe code block
resource "azurerm_lb_probe" "lb_probe" {
for_each = var.lb_details
name = each.value.probename
resource_group_name = var.rg_name
loadbalancer_id = azurerm_lb.vmss_lb.id
interval_in_seconds = 5
number_of_probes = 2
port = each.value.be_port
protocol = each.value.proto == "Udp" ? "Tcp" : each.value.proto
}
This will create a probe for each entry in the lb_details map
This will fail since, there are 2 probes with same name
it is not possible in azure, to create multiple probes with same backend port, so I cannot specify a new probe name
here is how I defined lb_rule
resource "azurerm_lb_rule" "lb_rule" {
for_each = var.lb_details
name = each.value.name
resource_group_name = var.rg_name
loadbalancer_id = azurerm_lb.vmss_lb.id
backend_address_pool_id = azurerm_lb_backend_address_pool.lb_be.id
frontend_ip_configuration_name = var.fe_ip_config
protocol = each.value.proto
frontend_port = each.value.fe_port
backend_port = each.value.be_port
probe_id = azurerm_lb_probe.lb_probe[each.key].id
load_distribution = lookup(each.value, "load_distribution", null)
}
(obviously other variables are defined )
any idea on how to accomplish this?