Add router BGP peers
This commit is contained in:
parent
02707eb275
commit
e835730665
|
@ -14,6 +14,20 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
locals {
|
||||
spoke_vms = flatten([
|
||||
for spoke_key, spoke in var.spokes : [
|
||||
for nva in spoke.nvas : {
|
||||
ip = nva.ip
|
||||
vm = nva.vm
|
||||
vm_name = element(split("/", nva.vm), length(split("/", nva.vm)) - 1)
|
||||
spoke_key = spoke_key
|
||||
spoke = spoke
|
||||
}
|
||||
]
|
||||
])
|
||||
}
|
||||
|
||||
resource "google_network_connectivity_hub" "ncc-hub" {
|
||||
project = var.project_id
|
||||
name = var.name
|
||||
|
@ -84,3 +98,31 @@ resource "google_compute_router_interface" "ncc-cr-if2" {
|
|||
private_ip_address = each.value.router.ip2
|
||||
redundant_interface = google_compute_router_interface.ncc-cr-if1[each.key].name
|
||||
}
|
||||
|
||||
resource "google_compute_router_peer" "ncc-cr-peer1" {
|
||||
for_each = {
|
||||
for entry in local.spoke_vms : entry.ip => entry
|
||||
}
|
||||
project = var.project_id
|
||||
name = "peer1-${each.value.vm_name}"
|
||||
router = google_compute_router.ncc-cr[each.value.spoke_key].name
|
||||
region = each.value.spoke.region
|
||||
interface = google_compute_router_interface.ncc-cr-if1[each.value.spoke_key].name
|
||||
peer_asn = each.value.spoke.router.peer_asn
|
||||
peer_ip_address = each.key
|
||||
router_appliance_instance = each.value.vm
|
||||
}
|
||||
|
||||
resource "google_compute_router_peer" "ncc-cr-peer2" {
|
||||
for_each = {
|
||||
for entry in local.spoke_vms : entry.ip => entry
|
||||
}
|
||||
project = var.project_id
|
||||
name = "peer2-${each.value.vm_name}"
|
||||
router = google_compute_router.ncc-cr[each.value.spoke_key].name
|
||||
region = each.value.spoke.region
|
||||
interface = google_compute_router_interface.ncc-cr-if2[each.value.spoke_key].name
|
||||
peer_asn = each.value.spoke.router.peer_asn
|
||||
peer_ip_address = each.key
|
||||
router_appliance_instance = each.value.vm
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue