From 4a8f590b7e10ce91ec8f907729b668ad9754a861 Mon Sep 17 00:00:00 2001 From: Awais Malik Date: Wed, 18 Oct 2023 11:22:44 -0700 Subject: [PATCH] removes lookup for existing routers --- modules/vpn_ha/main.tf | 12 ++---------- modules/vpn_ha/outputs.tf | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/modules/vpn_ha/main.tf b/modules/vpn_ha/main.tf index 910182a..f0adfa9 100644 --- a/modules/vpn_ha/main.tf +++ b/modules/vpn_ha/main.tf @@ -18,7 +18,7 @@ locals { router = ( var.router_name == "" - ? google_compute_router.router[0].name + ? google_compute_router.router.name : var.router_name ) peer_external_gateway = ( @@ -61,16 +61,8 @@ resource "google_compute_external_vpn_gateway" "external_gateway" { } } -data "google_compute_router" "router" { - name = var.router_name == null ? "" : var.router_name - network = var.network - project = var.project_id - region = var.region -} - resource "google_compute_router" "router" { - provider = google-beta - count = data.google_compute_router.router.name == null ? 1 : 0 + provider = google-beta name = var.router_name != "" ? var.router_name : "vpn-${var.name}" project = var.project_id region = var.region diff --git a/modules/vpn_ha/outputs.tf b/modules/vpn_ha/outputs.tf index 788106c..611e469 100644 --- a/modules/vpn_ha/outputs.tf +++ b/modules/vpn_ha/outputs.tf @@ -35,7 +35,7 @@ output "name" { output "router" { description = "Router resource (only if auto-created)." - value = var.router_name == "" ? google_compute_router.router[0] : null + value = var.router_name == "" ? google_compute_router.router : null } output "router_name" {