Im trying to see if its possible to run multiple for_each loops in one resource.
using the azurerm_private_dns_zone_virtual_network_link I have to pass in the name of the network id I want to create the link for.
Im already calling the module with a foreach, from the azurerm_private_dns_zone.
So what im trying to do, is create a dns zone virtual link, for each DNS Zone I’ve created (in the azurerm_private_dns_zone) and for each virtual network I want to link it to.
I tried passing a list, converting it to string, but it just combines the list elements together.
Not sure if what im trying is possible
`resource "azurerm_private_dns_zone_virtual_network_link" "dns_vnet_link" {
for_each = azurerm_private_dns_zone.prv_dns_zone
name = "${each.value.name}-vnet-link"
resource_group_name = var.resource_group_name
#virtual_network_id = [for vnet_id in var.vnet_id : format("%s", vnet_id)]
virtual_network_id = "${join(", ", [for vnet_id in var.vnet_id : format("%s", vnet_id)])}"
private_dns_zone_name = each.value.name
lifecycle {
ignore_changes = [tags]
}
}`
If I just pass one element in the list the above works, but just for one virtual network id.
Im thinking im going to need to use a local to create an object that contains the values I need and then pass them onto the resource…