From 1c1b149946c0f6da63f9d6c56fc0676baf240692 Mon Sep 17 00:00:00 2001 From: Miren Esnaola Date: Mon, 11 Sep 2023 14:10:17 +0200 Subject: [PATCH] Fix for partner interconnect, the router interface and the BGP peers are automatically created --- modules/net-vlan-attachment/README.md | 6 +++--- modules/net-vlan-attachment/main.tf | 13 +++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/net-vlan-attachment/README.md b/modules/net-vlan-attachment/README.md index b013fe08c0..095e3f0bf4 100644 --- a/modules/net-vlan-attachment/README.md +++ b/modules/net-vlan-attachment/README.md @@ -81,7 +81,7 @@ module "example-va" { name = google_compute_router.interconnect-router.name } } -# tftest modules=1 resources=3 +# tftest modules=1 resources=2 ``` ### Dedicated Interconnect - Two VLAN Attachments on a single region (99.9% SLA) @@ -201,7 +201,7 @@ module "example-va-b" { edge_availability_domain = "AVAILABILITY_DOMAIN_2" } } -# tftest modules=2 resources=5 +# tftest modules=2 resources=3 ``` ### Dedicated Interconnect - Four VLAN Attachments on two regions (99.99% SLA) @@ -431,7 +431,7 @@ module "example-va-b-ew12" { edge_availability_domain = "AVAILABILITY_DOMAIN_2" } } -# tftest modules=4 resources=10 +# tftest modules=4 resources=6 ``` ### IPSec over Interconnect enabled setup diff --git a/modules/net-vlan-attachment/main.tf b/modules/net-vlan-attachment/main.tf index 877ec4a7ad..5cf5c328e4 100644 --- a/modules/net-vlan-attachment/main.tf +++ b/modules/net-vlan-attachment/main.tf @@ -61,7 +61,15 @@ resource "google_compute_router" "encrypted" { region = var.region encrypted_interconnect_router = true bgp { - asn = var.router_config.asn + asn = var.router_config.asn + advertise_mode = var.dedicated_interconnect_config == null ? "DEFAULT" : "CUSTOM" + dynamic "advertised_ip_ranges" { + for_each = var.dedicated_interconnect_config == null ? var.ipsec_gateway_ip_ranges : {} + content { + description = advertised_ip_ranges.key + range = advertised_ip_ranges.value + } + } } } @@ -106,13 +114,14 @@ resource "google_compute_router_interface" "default" { } resource "google_compute_router_peer" "default" { + count = var.dedicated_interconnect_config != null ? 1 : 0 name = "${var.name}-peer" project = var.project_id router = local.router region = var.region peer_ip_address = split("/", google_compute_interconnect_attachment.default.customer_router_ip_address)[0] peer_asn = var.peer_asn - interface = "${var.name}-intf" + interface = google_compute_router_interface.default[0].name advertised_route_priority = 100 advertise_mode = "CUSTOM"