Group vpc and subnet under vpc_config

This commit is contained in:
Julio Diez 2023-03-09 09:54:43 +01:00
parent e9312e4dba
commit b25ee97d15
2 changed files with 9 additions and 11 deletions

View File

@ -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
}

View File

@ -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
})
}