eastus_rg = somerg
westeu_rg = somerg1
Input = {
Prod = [
{
cidr = ["172.0.0/24"]
vnet_name = "vnet1"
rg = "prodrg1"
location = "eastus"
},
{
cidr = ["172.1.0.0/24"]
vnet_name = "vnet2"
rg = "prodrg2"
location = "eastus"
}
],
nonProd = [
{
cidr = ["10.0.0/24"]
vnet_name = "NPvnet1"
rg = "nonprodrg1"
location = "eastus"
},
{
cidr = ["10.10.1.0/24"]
vnet_name = "NPvnet2"
rg = "nonprodrg2"
location = "eastus"
}
]
}
locals {
flat_vnet_rg_permissions = merge([
for env_name, env_vn_list in var.Input :
{
for idx, env_vn in env_vn_list:
"${env_name}-${idx}" => env_vn
}
]...)
}
data "azurerm_virtual_network" "westvnets" {
for_each = { for k, v in local.flat_vnet_rg_permissions : k => v if v.location == "westeu" }
name = each.value["vnet_name"]
resource_group_name = each.value.rg
}
resource "azurerm_virtual_network_peering" "peerwesthub" {
for_each = data.azurerm_virtual_network.westvnets
name = "vnet-peer-west"-${each.key}
remote_virtual_network_id = each.value.outputs.id
resource_group_name = each.value.rg
virtual_network_name = each.value.name
}
How would I proprly fetch the remote_virtual_network_id from each iteration of the above data source and also set a meaningful peer name that would help to identify ?