diff --git a/modules/ncc-spoke-ra/README.md b/modules/ncc-spoke-ra/README.md
index 58f5cd9103..d7dba8ea58 100644
--- a/modules/ncc-spoke-ra/README.md
+++ b/modules/ncc-spoke-ra/README.md
@@ -23,8 +23,8 @@ module "spoke-ra" {
]
router_config = {
asn = 65000
- ip_interface1 = "10.0.0.14"
- ip_interface2 = "10.0.0.15"
+ ip_interface0 = "10.0.0.14"
+ ip_interface1 = "10.0.0.15"
peer_asn = 65001
}
vpc_config = {
@@ -52,8 +52,8 @@ module "spoke-ra-a" {
]
router_config = {
asn = 65000
- ip_interface1 = "10.0.0.14"
- ip_interface2 = "10.0.0.15"
+ ip_interface0 = "10.0.0.14"
+ ip_interface1 = "10.0.0.15"
peer_asn = 65001
}
vpc_config = {
@@ -76,8 +76,8 @@ module "spoke-ra-b" {
]
router_config = {
asn = 65000
- ip_interface1 = "10.0.0.14"
- ip_interface2 = "10.0.0.15"
+ ip_interface0 = "10.0.0.14"
+ ip_interface1 = "10.0.0.15"
peer_asn = 65002
}
vpc_config = {
@@ -115,8 +115,8 @@ module "spoke-ra" {
"10.10.0.0/24" = "peered-vpc"
}
}
- ip_interface1 = "10.0.0.14"
- ip_interface2 = "10.0.0.15"
+ ip_interface0 = "10.0.0.14"
+ ip_interface1 = "10.0.0.15"
peer_asn = 65001
}
vpc_config = {
@@ -137,8 +137,8 @@ module "spoke-ra" {
| [project_id](variables.tf#L37) | The ID of the project where the NCC hub & spokes will be created. | string
| ✓ | |
| [region](variables.tf#L42) | Region where the spoke is located. | string
| ✓ | |
| [router_appliances](variables.tf#L47) | List of router appliances this spoke is associated with. | list(object({…}))
| ✓ | |
-| [router_config](variables.tf#L55) | Configuration of the Cloud Router. | object({…})
| ✓ | |
-| [vpc_config](variables.tf#L70) | Network and subnetwork for the CR interfaces. | object({…})
| ✓ | |
+| [router_config](variables.tf#L55) | Configuration of the Cloud Router. | object({…})
| ✓ | |
+| [vpc_config](variables.tf#L71) | Network and subnetwork for the CR interfaces. | object({…})
| ✓ | |
| [data_transfer](variables.tf#L17) | Site-to-site data transfer feature, available only in some regions. | bool
| | false
|
## Outputs
diff --git a/modules/ncc-spoke-ra/main.tf b/modules/ncc-spoke-ra/main.tf
index ab009dabbf..72ac20fa15 100644
--- a/modules/ncc-spoke-ra/main.tf
+++ b/modules/ncc-spoke-ra/main.tf
@@ -75,48 +75,50 @@ resource "google_compute_router" "cr" {
}
}
-resource "google_compute_router_interface" "intf1" {
+resource "google_compute_router_interface" "intf_0" {
project = var.project_id
- name = "intf1"
+ name = "${google_compute_router.cr.name}-intf0"
router = google_compute_router.cr.name
region = var.region
subnetwork = var.vpc_config.subnet_self_link
- private_ip_address = var.router_config.ip_interface1
+ private_ip_address = var.router_config.ip_interface0
}
-resource "google_compute_router_interface" "intf2" {
+resource "google_compute_router_interface" "intf_1" {
project = var.project_id
- name = "intf2"
+ name = "${google_compute_router.cr.name}-intf1"
router = google_compute_router.cr.name
region = var.region
subnetwork = var.vpc_config.subnet_self_link
- private_ip_address = var.router_config.ip_interface2
- redundant_interface = google_compute_router_interface.intf1.name
+ private_ip_address = var.router_config.ip_interface1
+ redundant_interface = google_compute_router_interface.intf_0.name
}
-resource "google_compute_router_peer" "peer1" {
+resource "google_compute_router_peer" "peer_0" {
for_each = {
for idx, entry in local.spoke_vms : idx => entry
}
project = var.project_id
- name = "peer1-${each.value.vm_name}"
+ name = "${google_compute_router.cr.name}-${each.value.vm_name}-peer1"
router = google_compute_router.cr.name
region = var.region
- interface = google_compute_router_interface.intf1.name
+ advertised_route_priority = var.router_config.routes_priority
+ interface = google_compute_router_interface.intf_0.name
peer_asn = var.router_config.peer_asn
peer_ip_address = each.value.ip
router_appliance_instance = each.value.vm
}
-resource "google_compute_router_peer" "peer2" {
+resource "google_compute_router_peer" "peer_1" {
for_each = {
for idx, entry in local.spoke_vms : idx => entry
}
project = var.project_id
- name = "peer2-${each.value.vm_name}"
+ name = "${google_compute_router.cr.name}-${each.value.vm_name}-peer2"
router = google_compute_router.cr.name
region = var.region
- interface = google_compute_router_interface.intf2.name
+ advertised_route_priority = var.router_config.routes_priority
+ interface = google_compute_router_interface.intf_1.name
peer_asn = var.router_config.peer_asn
peer_ip_address = each.value.ip
router_appliance_instance = each.value.vm
diff --git a/modules/ncc-spoke-ra/variables.tf b/modules/ncc-spoke-ra/variables.tf
index 1e3a6df38b..1728665137 100644
--- a/modules/ncc-spoke-ra/variables.tf
+++ b/modules/ncc-spoke-ra/variables.tf
@@ -60,10 +60,11 @@ variable "router_config" {
all_subnets = bool
ip_ranges = map(string)
}))
- ip_interface1 = string
- ip_interface2 = string
- keepalive = optional(number)
- peer_asn = number
+ ip_interface0 = string
+ ip_interface1 = string
+ keepalive = optional(number)
+ peer_asn = number
+ routes_priority = optional(number, 100)
})
}