diff --git a/infra/partner-mainnet/network.tf b/infra/partner-mainnet/network.tf index 8f82f6859..a48189add 100644 --- a/infra/partner-mainnet/network.tf +++ b/infra/partner-mainnet/network.tf @@ -42,6 +42,7 @@ module "vpc" { } resource "google_compute_router" "router" { + count = var.create_network ? 1 : 0 name = "default" network = var.network project = var.project_id @@ -49,9 +50,10 @@ resource "google_compute_router" "router" { } resource "google_compute_router_nat" "nat" { - name = "nat" - router = google_compute_router.router.name - region = var.region - nat_ip_allocate_option = "AUTO_ONLY" + count = var.create_network ? 1 : 0 + name = "nat" + router = google_compute_router.router[count.index].name + region = var.region + nat_ip_allocate_option = "AUTO_ONLY" source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES" } \ No newline at end of file