From b25ee97d1513202d8bf466a04d8576e4ae5e3b13 Mon Sep 17 00:00:00 2001 From: Julio Diez Date: Thu, 9 Mar 2023 09:54:43 +0100 Subject: [PATCH] Group vpc and subnet under vpc_config --- modules/ncc-spoke-ra/main.tf | 6 +++--- modules/ncc-spoke-ra/variables.tf | 14 ++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/ncc-spoke-ra/main.tf b/modules/ncc-spoke-ra/main.tf index 78a034e9..66e6194f 100644 --- a/modules/ncc-spoke-ra/main.tf +++ b/modules/ncc-spoke-ra/main.tf @@ -51,7 +51,7 @@ resource "google_network_connectivity_spoke" "spoke-ra" { resource "google_compute_router" "cr" { project = var.project_id name = "${var.name}-cr" - network = var.vpc + network = var.vpc_config.network_name region = var.region bgp { advertise_mode = ( @@ -78,7 +78,7 @@ resource "google_compute_router_interface" "intf1" { name = "intf1" router = google_compute_router.cr.name region = var.region - subnetwork = var.subnetwork + subnetwork = var.vpc_config.subnet_self_link private_ip_address = var.ip_intf1 } @@ -87,7 +87,7 @@ resource "google_compute_router_interface" "intf2" { name = "intf2" router = google_compute_router.cr.name region = var.region - subnetwork = var.subnetwork + subnetwork = var.vpc_config.subnet_self_link private_ip_address = var.ip_intf2 redundant_interface = google_compute_router_interface.intf1.name } diff --git a/modules/ncc-spoke-ra/variables.tf b/modules/ncc-spoke-ra/variables.tf index 410e30b9..2c54c0d7 100644 --- a/modules/ncc-spoke-ra/variables.tf +++ b/modules/ncc-spoke-ra/variables.tf @@ -89,12 +89,10 @@ variable "region" { type = string } -variable "subnetwork" { - description = "The URI of the subnetwork that CR interfaces belong to." - type = string -} - -variable "vpc" { - description = "A reference to the network to which the CR belongs." - type = string +variable "vpc_config" { + description = "Network and subnetwork for the CR interfaces." + type = object({ + network_name = string + subnet_self_link = string + }) }