Good afternoon. I am looking to create a data structure to create azure route entries.
This map contains all the default rules that get added to every route table:
spoke_template = {
route_entries = {
blackhole_mgmt = {
name = "BlackholeManagement"
prefix = "10.121.0.0/28"
next_hop_type = "None"
}
blackhole_untrust = {
name = "BlackholeUntrust"
prefix = "10.121.0.16/28"
next_hop_type = "None"
}
blackhole_trust_ext = {
name = "BlackholeTrustExt"
prefix = "10.121.0.48/28"
next_hop_type = "None"
}
blackhole_fwHA = {
name = "BlackholefwHA"
prefix = "10.121.0.64/28"
next_hop_type = "None"
}
blackhole_app_gwy = {
name = "BlackholeAppGateway"
prefix = "10.121.0.128/25"
next_hop_type = "None"
}
rfc-1918-10 = {
name = "RFC-1918-10"
prefix = "10.0.0.0/8"
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.36"
}
rfc-1918-172 = {
name = "RFC-1918-172"
prefix = "172.16.0.0/12"
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.36"
}
rfc-1918-192 = {
name = "RFC-1918-192"
prefix = "192.168.0.0/16"
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.36"
}
default-route = {
name = "default"
prefix = "0.0.0.0/0"
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.50"
}
}
}
This map defines the vnets, subnets, and per-subnet routes:
spokes = {
vnet-app1-it-dev-use2-001 = {
resource_group_name = "rg-app1-net-it-dev-use2"
sn-web-dev = {
route_entries = {
intra-subnet = {
name = "Intra-VNet"
prefix = "10.121.96.0/28" # Dynamic
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.36"
}
intra-vnet = {
name = "Intra-VNet"
prefix = "10.121.96.0/24" # Dynamic
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.36"
}
}
}
sn-app-dev = {
route_entries = {
intra-subnet = {
name = "Intra-VNet"
prefix = "10.121.96.16/28"
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.36"
}
intra-vnet = {
name = "Intra-VNet"
prefix = "10.121.96.0/24"
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.36"
}
}
}
sn-db-dev = {
route_entries = {
intra-subnet = {
name = "Intra-VNet"
prefix = "10.121.96.32/28"
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.36"
}
intra-vnet = {
name = "Intra-VNet"
prefix = "10.121.96.0/24"
next_hop_type = "VirtualAppliance"
next_hop_type_ip = "10.121.0.36"
}
}
}
}
}
Ideally, I would like to loop the spokes map and add the spoke_template map route_entries along with the custom route entries in the spokes map. I am unsure of the proper way to design the maps so that I can loop and merge them. Any help would be greatly appreciated. Thanks.