Skip to content

Commit

Permalink
feat: conditionally create Google DNS and compute resources based on …
Browse files Browse the repository at this point in the history
…VPC variable
  • Loading branch information
Gezi-lzq committed Nov 27, 2024
1 parent 8600891 commit 52a1385
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions google.tf
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ resource "google_dns_managed_zone" "private_dns_zone" {


resource "google_dns_managed_zone" "private_googleapis" {
count = var.create_new_vpc ? 1 : 0
name = "private-gapis-${var.automq_byoc_env_id}"
dns_name = "googleapis.com."
description = "Private zone for Google APIs"
Expand All @@ -445,6 +446,7 @@ resource "google_dns_managed_zone" "private_googleapis" {
}

resource "google_dns_record_set" "wildcard_googleapis_cname" {
count = var.create_new_vpc ? 1 : 0
name = "*.googleapis.com."
managed_zone = google_dns_managed_zone.private_googleapis.name
type = "CNAME"
Expand All @@ -453,6 +455,7 @@ resource "google_dns_record_set" "wildcard_googleapis_cname" {
}

resource "google_dns_record_set" "private_googleapis_ipv4" {
count = var.create_new_vpc ? 1 : 0
name = "private.googleapis.com."
managed_zone = google_dns_managed_zone.private_googleapis.name
type = "A"
Expand All @@ -461,6 +464,7 @@ resource "google_dns_record_set" "private_googleapis_ipv4" {
}

resource "google_compute_route" "route_ipv4_googleapi" {
count = var.create_new_vpc ? 1 : 0
name = "route-to-gapis-ipv4-${var.automq_byoc_env_id}"
network = data.google_compute_network.vpc.id
dest_range = "199.36.153.8/30"
Expand All @@ -470,6 +474,7 @@ resource "google_compute_route" "route_ipv4_googleapi" {
}

resource "google_compute_route" "route_ipv4_googleapi_additional" {
count = var.create_new_vpc ? 1 : 0
name = "route-to-gapis-ipv4-additional-${var.automq_byoc_env_id}"
network = data.google_compute_network.vpc.id
dest_range = "34.126.0.0/18"
Expand All @@ -479,6 +484,7 @@ resource "google_compute_route" "route_ipv4_googleapi_additional" {
}

resource "google_compute_firewall" "allow_googleapis_ipv4" {
count = var.create_new_vpc ? 1 : 0
name = "allow-out-gapis-ipv4-${var.automq_byoc_env_id}"
network = data.google_compute_network.vpc.name

Expand Down

0 comments on commit 52a1385

Please sign in to comment.