Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dns refactory #130

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7f3dbcf
DNS Refactory for hub-and-spoke
renato-rudnicki Nov 1, 2024
20fd603
remove dns-hub.tf
renato-rudnicki Nov 4, 2024
5ee619b
remove dns_hub code
renato-rudnicki Nov 6, 2024
7f6644d
fix lint and module names
renato-rudnicki Nov 6, 2024
b6e1cf8
change conditional for advertised_ip_ranges
renato-rudnicki Nov 6, 2024
b6810c7
Merge branch 'master' into dns-refactory
renato-rudnicki Nov 7, 2024
573bdf4
removing dns_hub_project_id references
renato-rudnicki Nov 12, 2024
62274d7
fix project for vpc_dns_hub
renato-rudnicki Nov 14, 2024
e39a508
fix base_shared project value
renato-rudnicki Nov 14, 2024
8306009
fix shared network
renato-rudnicki Nov 21, 2024
f7c4d14
fix advertised_ip_ranges
renato-rudnicki Nov 27, 2024
04dbfcc
change advertised_ip_ranges to local advertised_ip
renato-rudnicki Dec 6, 2024
b27c513
remove target_name_server_addresses from dev/prod/nonprod
renato-rudnicki Dec 6, 2024
770b957
remove dns-hub from dual_shared_vpc
renato-rudnicki Dec 12, 2024
71eda88
DNS Forward for dual-shared-vpc
renato-rudnicki Dec 13, 2024
576a942
dual-shared-vpc-changes
renato-rudnicki Dec 19, 2024
d92c5ce
fix lint
renato-rudnicki Dec 19, 2024
cc17b6a
refactoy DNS Dual-Shared
renato-rudnicki Dec 20, 2024
30000d3
Merge branch 'master' into dns-refactory
renato-rudnicki Dec 26, 2024
e9867b6
remove comments and update code
renato-rudnicki Dec 26, 2024
1557bd0
Changes related to PR review
renato-rudnicki Dec 27, 2024
7b3b67f
Merge branch 'master' into dns-refactory
renato-rudnicki Jan 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions 3-networks-hub-and-spoke/envs/shared/interconnect.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,6 @@
* limitations under the License.
*/

module "dns_hub_interconnect" {
source = "../../modules/dedicated_interconnect"

vpc_name = "vpc-net-dns"
interconnect_project_id = local.dns_hub_project_id

region1 = local.default_region1
region1_router1_name = module.dns_hub_region1_router1.router.name
region1_interconnect1_candidate_subnets = ["169.254.0.0/29"]
region1_interconnect1_vlan_tag8021q = "3931"
region1_interconnect1 = "https://www.googleapis.com/compute/v1/projects/${local.interconnect_project_id}/global/interconnects/example-interconnect-1"
region1_interconnect1_location = "las-zone1-770"
region1_interconnect1_onprem_dc = "onprem-dc1"
region1_router2_name = module.dns_hub_region1_router2.router.name
region1_interconnect2_candidate_subnets = ["169.254.0.8/29"]
region1_interconnect2_vlan_tag8021q = "3932"
region1_interconnect2 = "https://www.googleapis.com/compute/v1/projects/${local.interconnect_project_id}/global/interconnects/example-interconnect-2"
region1_interconnect2_location = "las-zone1-770"
region1_interconnect2_onprem_dc = "onprem-dc2"

region2 = local.default_region2
region2_router1_name = module.dns_hub_region2_router1.router.name
region2_interconnect1_candidate_subnets = ["169.254.0.16/29"]
region2_interconnect1_vlan_tag8021q = "3933"
region2_interconnect1 = "https://www.googleapis.com/compute/v1/projects/${local.interconnect_project_id}/global/interconnects/example-interconnect-3"
region2_interconnect1_location = "lax-zone2-19"
region2_interconnect1_onprem_dc = "onprem-dc3"
region2_router2_name = module.dns_hub_region2_router2.router.name
region2_interconnect2_candidate_subnets = ["169.254.0.24/29"]
region2_interconnect2_vlan_tag8021q = "3934"
region2_interconnect2 = "https://www.googleapis.com/compute/v1/projects/${local.interconnect_project_id}/global/interconnects/example-interconnect-4"
region2_interconnect2_location = "lax-zone1-403"
region2_interconnect2_onprem_dc = "onprem-dc4"

peer_asn = "64515"
peer_name = "interconnect-peer"

cloud_router_labels = {
vlan_1 = "cr1",
vlan_2 = "cr2",
vlan_3 = "cr3",
vlan_4 = "cr4"
}
}

module "shared_restricted_interconnect" {
source = "../../modules/dedicated_interconnect"
Expand Down
2 changes: 0 additions & 2 deletions 3-networks-hub-and-spoke/envs/shared/net-hubs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ module "base_shared_vpc" {
]
secondary_ranges = {}

depends_on = [module.dns_hub_vpc]
}

/******************************************
Expand Down Expand Up @@ -337,5 +336,4 @@ module "restricted_shared_vpc" {

ingress_policies = var.ingress_policies

depends_on = [module.dns_hub_vpc]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,6 @@
*/


module "dns_hub_interconnect" {
source = "../../modules/partner_interconnect"

vpc_name = "vpc-net-dns"
attachment_project_id = local.dns_hub_project_id
preactivate = var.preactivate_partner_interconnect

region1 = local.default_region1
region1_router1_name = module.dns_hub_region1_router1.router.name
region1_interconnect1_location = "las-zone1-770"
region1_interconnect1_onprem_dc = "onprem-dc-1"
region1_router2_name = module.dns_hub_region1_router2.router.name
region1_interconnect2_location = "las-zone1-770"
region1_interconnect2_onprem_dc = "onprem-dc-2"

region2 = local.default_region2
region2_router1_name = module.dns_hub_region2_router1.router.name
region2_interconnect1_location = "lax-zone2-19"
region2_interconnect1_onprem_dc = "onprem-dc-3"
region2_router2_name = module.dns_hub_region2_router2.router.name
region2_interconnect2_location = "lax-zone1-403"
region2_interconnect2_onprem_dc = "onprem-dc-4"

cloud_router_labels = {
vlan_1 = "cr1",
vlan_2 = "cr2",
vlan_3 = "cr3",
vlan_4 = "cr4"
}
}

module "shared_restricted_interconnect" {
source = "../../modules/partner_interconnect"

Expand Down
10 changes: 5 additions & 5 deletions 3-networks-hub-and-spoke/modules/base_shared_vpc/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ module "peering_zone" {
/******************************************
DNS Forwarding
*****************************************/
module "dns-forwarding-zone" {
module "dns_forwarding_zone" {
source = "terraform-google-modules/cloud-dns/google"
version = "~> 5.0"

count = var.mode != "spoke" ? 1 : 0
count = var.mode != "spoke" ? 1 : 0

project_id = var.project_id
type = "forwarding"
name = "fz-dns-hub"
domain = var.domain

private_visibility_config_networks = [
module.dns_hub_vpc.network_self_link
module.main.network_self_link
]
target_name_server_addresses = data.google_compute_network.vpc_dns_hub.self_link
}
target_network = data.google_compute_network.vpc_dns_hub.self_link
}
48 changes: 24 additions & 24 deletions 3-networks-hub-and-spoke/modules/base_shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ module "region1_router1" {
network = module.main.network_name
region = var.default_region1
bgp = {
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = [
{ range = local.private_googleapis_cidr },
{ range = "35.199.192.0/19" }
]
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = concat(
[{ range = local.private_googleapis_cidr }],
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
)
}
}

Expand All @@ -143,12 +143,12 @@ module "region1_router2" {
network = module.main.network_name
region = var.default_region1
bgp = {
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = [
{ range = local.private_googleapis_cidr },
{ range = "35.199.192.0/19" }
]
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = concat(
[{ range = local.private_googleapis_cidr }],
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
)
}
}

Expand All @@ -162,12 +162,12 @@ module "region2_router1" {
network = module.main.network_name
region = var.default_region2
bgp = {
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = [
{ range = local.private_googleapis_cidr },
{ range = "35.199.192.0/19" }
]
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = concat(
[{ range = local.private_googleapis_cidr }],
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same value for each router.
this could be on a local

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

Expand All @@ -181,11 +181,11 @@ module "region2_router2" {
network = module.main.network_name
region = var.default_region2
bgp = {
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = [
{ range = local.private_googleapis_cidr },
{ range = "35.199.192.0/19" }
]
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = concat(
[{ range = local.private_googleapis_cidr }],
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
)
}
}
8 changes: 4 additions & 4 deletions 3-networks-hub-and-spoke/modules/restricted_shared_vpc/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ module "peering_zone" {
/******************************************
DNS Forwarding
*****************************************/
module "dns-forwarding-zone" {
module "dns_forwarding_zone" {
source = "terraform-google-modules/cloud-dns/google"
version = "~> 5.0"

count = var.mode != "spoke" ? 1 : 0
count = var.mode != "spoke" ? 1 : 0

project_id = var.project_id
type = "forwarding"
name = "fz-dns-hub"
domain = var.domain

private_visibility_config_networks = [
module.dns_hub_vpc.network_self_link
module.main.network_self_link
]
target_name_server_addresses = data.google_compute_network.vpc_dns_hub.self_link
target_network = data.google_compute_network.vpc_dns_hub.self_link
}
48 changes: 24 additions & 24 deletions 3-networks-hub-and-spoke/modules/restricted_shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ module "region1_router1" {
network = module.main.network_name
region = var.default_region1
bgp = {
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = [
{ range = local.restricted_googleapis_cidr },
{ range = "35.199.192.0/19" }
]
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = concat(
[{ range = local.restricted_googleapis_cidr }],
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
)
}
}

Expand All @@ -147,12 +147,12 @@ module "region1_router2" {
network = module.main.network_name
region = var.default_region1
bgp = {
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = [
{ range = local.restricted_googleapis_cidr },
{ range = "35.199.192.0/19" }
]
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = concat(
[{ range = local.restricted_googleapis_cidr }],
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
)
}
}

Expand All @@ -166,12 +166,12 @@ module "region2_router1" {
network = module.main.network_name
region = var.default_region2
bgp = {
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = [
{ range = local.restricted_googleapis_cidr },
{ range = "35.199.192.0/19" }
]
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = concat(
[{ range = local.restricted_googleapis_cidr }],
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
)
}
}

Expand All @@ -185,11 +185,11 @@ module "region2_router2" {
network = module.main.network_name
region = var.default_region2
bgp = {
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = [
{ range = local.restricted_googleapis_cidr },
{ range = "35.199.192.0/19" }
]
asn = var.bgp_asn_subnet
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges = concat(
[{ range = local.restricted_googleapis_cidr }],
var.private_service_cidr != null ? [{ range = "35.199.192.0/19" }] : []
)
}
}