I’m trying to build out an Azure firewall, some public IP’s and some NAT rules associated with them.
I’m running into difficulty referencing the public IP’s i’ve made in the resource in my nat rules. Since the nat rules use a count and then a nested for_each loop I can’t figure out how to have them properly reference the public IP they will be using.
My current attempt is I add the name of the public_ip manually in the var.firewall_nat_collection and am trying to filter the azurerm_public_ip.rg_public_IPs but this only returns an empty field and doesn’t seem to match.
destination_addresses = [for ip_address, name in azurerm_public_ip.rg_public_IPs : ip_address if name == rule.value.public_ip]
Let me know what is wrong with my for statement or if there is a better way to achieve this?
relevant code: https://privatebin.net/?ec855204f5cc2d07#4YeSTx7wUjNpQq134AqZH2chiSRt2m3u5Ck4haQyPZxf