Skip to content

Commit

Permalink
fix: add support for empty networks (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-teller authored Jul 19, 2023
1 parent 2b1cb88 commit 54f6504
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ resource "google_dns_managed_zone" "peering" {
visibility = "private"
force_destroy = var.force_destroy

private_visibility_config {
dynamic "networks" {
for_each = var.private_visibility_config_networks
content {
network_url = networks.value
dynamic "private_visibility_config" {
for_each = length(var.private_visibility_config_networks) > 0 ? [1] : []
content {
dynamic "networks" {
for_each = var.private_visibility_config_networks
content {
network_url = networks.value
}
}
}
}
Expand All @@ -52,11 +55,14 @@ resource "google_dns_managed_zone" "forwarding" {
visibility = "private"
force_destroy = var.force_destroy

private_visibility_config {
dynamic "networks" {
for_each = var.private_visibility_config_networks
content {
network_url = networks.value
dynamic "private_visibility_config" {
for_each = length(var.private_visibility_config_networks) > 0 ? [1] : []
content {
dynamic "networks" {
for_each = var.private_visibility_config_networks
content {
network_url = networks.value
}
}
}
}
Expand All @@ -66,7 +72,7 @@ resource "google_dns_managed_zone" "forwarding" {
for_each = var.target_name_server_addresses
content {
ipv4_address = target_name_servers.value.ipv4_address
forwarding_path = target_name_servers.value.forwarding_path
forwarding_path = lookup(target_name_servers.value, "forwarding_path", "default")
}
}
}
Expand All @@ -82,11 +88,14 @@ resource "google_dns_managed_zone" "private" {
visibility = "private"
force_destroy = var.force_destroy

private_visibility_config {
dynamic "networks" {
for_each = var.private_visibility_config_networks
content {
network_url = networks.value
dynamic "private_visibility_config" {
for_each = length(var.private_visibility_config_networks) > 0 ? [1] : []
content {
dynamic "networks" {
for_each = var.private_visibility_config_networks
content {
network_url = networks.value
}
}
}
}
Expand Down Expand Up @@ -142,11 +151,14 @@ resource "google_dns_managed_zone" "reverse_lookup" {
force_destroy = var.force_destroy
reverse_lookup = true

private_visibility_config {
dynamic "networks" {
for_each = var.private_visibility_config_networks
content {
network_url = networks.value
dynamic "private_visibility_config" {
for_each = length(var.private_visibility_config_networks) > 0 ? [1] : []
content {
dynamic "networks" {
for_each = var.private_visibility_config_networks
content {
network_url = networks.value
}
}
}
}
Expand Down

0 comments on commit 54f6504

Please sign in to comment.