From 9723cc2a5763566a001011ca399b95f42289a6a1 Mon Sep 17 00:00:00 2001 From: apichick Date: Tue, 7 Jan 2025 18:07:55 +0100 Subject: [PATCH] Added BGP priority variable for dedicated interconnect because it was harcoded to 100 and removed default bgp range, so it can be automatically picked up if not specified (#2802) --- modules/net-vlan-attachment/README.md | 24 ++++++++++++------------ modules/net-vlan-attachment/main.tf | 2 +- modules/net-vlan-attachment/variables.tf | 5 +++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/modules/net-vlan-attachment/README.md b/modules/net-vlan-attachment/README.md index 00ade1937..a72cb9387 100644 --- a/modules/net-vlan-attachment/README.md +++ b/modules/net-vlan-attachment/README.md @@ -646,19 +646,19 @@ module "example-va-b" { | name | description | type | required | default | |---|---|:---:|:---:|:---:| -| [description](variables.tf#L35) | VLAN attachment description. | string | ✓ | | -| [name](variables.tf#L52) | The common resources name, used after resource type prefix and suffix. | string | ✓ | | -| [network](variables.tf#L57) | The VPC name to which resources are associated to. | string | ✓ | | -| [peer_asn](variables.tf#L74) | The on-premises underlay router ASN. | string | ✓ | | -| [project_id](variables.tf#L79) | The project id where resources are created. | string | ✓ | | -| [region](variables.tf#L84) | The region where resources are created. | string | ✓ | | -| [router_config](variables.tf#L89) | Cloud Router configuration for the VPN. If you want to reuse an existing router, set create to false and use name to specify the desired router. | object({…}) | ✓ | | +| [description](variables.tf#L36) | VLAN attachment description. | string | ✓ | | +| [name](variables.tf#L53) | The common resources name, used after resource type prefix and suffix. | string | ✓ | | +| [network](variables.tf#L58) | The VPC name to which resources are associated to. | string | ✓ | | +| [peer_asn](variables.tf#L75) | The on-premises underlay router ASN. | string | ✓ | | +| [project_id](variables.tf#L80) | The project id where resources are created. | string | ✓ | | +| [region](variables.tf#L85) | The region where resources are created. | string | ✓ | | +| [router_config](variables.tf#L90) | Cloud Router configuration for the VPN. If you want to reuse an existing router, set create to false and use name to specify the desired router. | object({…}) | ✓ | | | [admin_enabled](variables.tf#L17) | Whether the VLAN attachment is enabled. | bool | | true | -| [dedicated_interconnect_config](variables.tf#L23) | Partner interconnect configuration. | object({…}) | | null | -| [ipsec_gateway_ip_ranges](variables.tf#L40) | IPSec Gateway IP Ranges. | map(string) | | {} | -| [mtu](variables.tf#L46) | The MTU associated to the VLAN attachment (1440 / 1500). | number | | 1500 | -| [partner_interconnect_config](variables.tf#L62) | Partner interconnect configuration. | object({…}) | | null | -| [vpn_gateways_ip_range](variables.tf#L114) | The IP range (cidr notation) to be used for the GCP VPN gateways. If null IPSec over Interconnect is not enabled. | string | | null | +| [dedicated_interconnect_config](variables.tf#L23) | Dedicated interconnect configuration. | object({…}) | | null | +| [ipsec_gateway_ip_ranges](variables.tf#L41) | IPSec Gateway IP Ranges. | map(string) | | {} | +| [mtu](variables.tf#L47) | The MTU associated to the VLAN attachment (1440 / 1500). | number | | 1500 | +| [partner_interconnect_config](variables.tf#L63) | Partner interconnect configuration. | object({…}) | | null | +| [vpn_gateways_ip_range](variables.tf#L115) | The IP range (cidr notation) to be used for the GCP VPN gateways. If null IPSec over Interconnect is not enabled. | string | | null | ## Outputs diff --git a/modules/net-vlan-attachment/main.tf b/modules/net-vlan-attachment/main.tf index ae1840cf7..40b2c81f6 100644 --- a/modules/net-vlan-attachment/main.tf +++ b/modules/net-vlan-attachment/main.tf @@ -123,7 +123,7 @@ resource "google_compute_router_peer" "default" { peer_ip_address = split("/", google_compute_interconnect_attachment.default.customer_router_ip_address)[0] peer_asn = var.peer_asn interface = google_compute_router_interface.default[0].name - advertised_route_priority = 100 + advertised_route_priority = var.dedicated_interconnect_config.bgp_priority advertise_mode = "CUSTOM" dynamic "advertised_ip_ranges" { diff --git a/modules/net-vlan-attachment/variables.tf b/modules/net-vlan-attachment/variables.tf index c8e55fb46..cd87b39c9 100644 --- a/modules/net-vlan-attachment/variables.tf +++ b/modules/net-vlan-attachment/variables.tf @@ -21,11 +21,12 @@ variable "admin_enabled" { } variable "dedicated_interconnect_config" { - description = "Partner interconnect configuration." + description = "Dedicated interconnect configuration." type = object({ # Possible values @ https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_interconnect_attachment#bandwidth bandwidth = optional(string, "BPS_10G") - bgp_range = optional(string, "169.254.128.0/29") + bgp_range = optional(string) + bgp_priority = optional(number) interconnect = string vlan_tag = string })