Skip to content

Commit

Permalink
chore(projects): fix network envcodes (#1199)
Browse files Browse the repository at this point in the history
  • Loading branch information
eeaton authored May 8, 2024
1 parent 9b7874d commit 1822e42
Show file tree
Hide file tree
Showing 16 changed files with 53 additions and 54 deletions.
13 changes: 6 additions & 7 deletions 1-org/envs/shared/projects.tf
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ module "interconnect" {
random_project_id = true
random_project_id_length = 4
default_service_account = "deprivilege"
name = "${local.project_prefix}-c-interconnect"
name = "${local.project_prefix}-net-interconnect"
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.network.id
Expand Down Expand Up @@ -234,7 +234,7 @@ module "dns_hub" {
random_project_id = true
random_project_id_length = 4
default_service_account = "deprivilege"
name = "${local.project_prefix}-c-dns-hub"
name = "${local.project_prefix}-net-dns"
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.network.id
Expand Down Expand Up @@ -276,7 +276,7 @@ module "base_network_hub" {
random_project_id = true
random_project_id_length = 4
default_service_account = "deprivilege"
name = "${local.project_prefix}-c-base-net-hub"
name = "${local.project_prefix}-net-hub-base"
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.network.id
Expand All @@ -292,8 +292,7 @@ module "base_network_hub" {

labels = {
environment = "network"
environment = "production"
application_name = "org-base-net-hub"
application_name = "org-net-hub-base"
billing_code = "1234"
primary_contact = "example1"
secondary_contact = "example2"
Expand Down Expand Up @@ -327,7 +326,7 @@ module "restricted_network_hub" {
random_project_id = true
random_project_id_length = 4
default_service_account = "deprivilege"
name = "${local.project_prefix}-c-restricted-net-hub"
name = "${local.project_prefix}-net-hub-restricted"
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.network.id
Expand All @@ -343,7 +342,7 @@ module "restricted_network_hub" {

labels = {
environment = "network"
application_name = "org-restricted-net-hub"
application_name = "org-net-hub-restricted"
billing_code = "1234"
primary_contact = "example1"
secondary_contact = "example2"
Expand Down
16 changes: 8 additions & 8 deletions 3-networks-dual-svpc/envs/shared/dns-hub.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ module "dns_hub_vpc" {
version = "~> 9.0"

project_id = local.dns_hub_project_id
network_name = "vpc-c-dns-hub"
network_name = "vpc-net-dns"
shared_vpc_host = "false"
delete_default_internet_gateway_routes = "true"

subnets = [{
subnet_name = "sb-c-dns-hub-${local.default_region1}"
subnet_name = "sb-net-dns-${local.default_region1}"
subnet_ip = "172.16.0.0/25"
subnet_region = local.default_region1
subnet_private_access = "true"
Expand All @@ -40,7 +40,7 @@ module "dns_hub_vpc" {
subnet_flow_logs_filter = var.vpc_flow_logs.filter_expr
description = "DNS hub subnet for region 1."
}, {
subnet_name = "sb-c-dns-hub-${local.default_region2}"
subnet_name = "sb-net-dns-${local.default_region2}"
subnet_ip = "172.16.0.128/25"
subnet_region = local.default_region2
subnet_private_access = "true"
Expand All @@ -54,7 +54,7 @@ module "dns_hub_vpc" {
}]

routes = [{
name = "rt-c-dns-hub-1000-all-default-private-api"
name = "rt-net-dns-1000-all-default-private-api"
description = "Route through IGW to allow private google api access."
destination_range = "199.36.153.8/30"
next_hop_internet = "true"
Expand Down Expand Up @@ -103,7 +103,7 @@ module "dns_hub_region1_router1" {
source = "terraform-google-modules/cloud-router/google"
version = "~> 6.0"

name = "cr-c-dns-hub-${local.default_region1}-cr1"
name = "cr-net-dns-${local.default_region1}-cr1"
project = local.dns_hub_project_id
network = module.dns_hub_vpc.network_name
region = local.default_region1
Expand All @@ -117,7 +117,7 @@ module "dns_hub_region1_router2" {
source = "terraform-google-modules/cloud-router/google"
version = "~> 6.0"

name = "cr-c-dns-hub-${local.default_region1}-cr2"
name = "cr-net-dns-${local.default_region1}-cr2"
project = local.dns_hub_project_id
network = module.dns_hub_vpc.network_name
region = local.default_region1
Expand All @@ -131,7 +131,7 @@ module "dns_hub_region2_router1" {
source = "terraform-google-modules/cloud-router/google"
version = "~> 6.0"

name = "cr-c-dns-hub-${local.default_region2}-cr3"
name = "cr-net-dns-${local.default_region2}-cr3"
project = local.dns_hub_project_id
network = module.dns_hub_vpc.network_name
region = local.default_region2
Expand All @@ -145,7 +145,7 @@ module "dns_hub_region2_router2" {
source = "terraform-google-modules/cloud-router/google"
version = "~> 6.0"

name = "cr-c-dns-hub-${local.default_region2}-cr4"
name = "cr-net-dns-${local.default_region2}-cr4"
project = local.dns_hub_project_id
network = module.dns_hub_vpc.network_name
region = local.default_region2
Expand Down
2 changes: 1 addition & 1 deletion 3-networks-dual-svpc/envs/shared/interconnect.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module "dns_hub_interconnect" {
source = "../../modules/dedicated_interconnect"

vpc_name = "c-dns-hub"
vpc_name = "net-dns"
interconnect_project_id = local.dns_hub_project_id

region1 = local.default_region1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module "dns_hub_interconnect" {
source = "../../modules/partner_interconnect"

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

Expand Down
2 changes: 1 addition & 1 deletion 3-networks-dual-svpc/modules/base_shared_vpc/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ resource "google_dns_policy" "default_policy" {
Creates DNS Peering to DNS HUB
*****************************************/
data "google_compute_network" "vpc_dns_hub" {
name = "vpc-c-dns-hub"
name = "vpc-net-dns"
project = var.dns_hub_project_id
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This module implements the recommendation proposed in [Establishing 99.99% Avail

## Prerequisites

1. Provisioning of four [VLAN attachments](https://cloud.google.com/network-connectivity/docs/interconnect/concepts/partner-overview) in the Hub project in the specified environment. That would be the `prj-{p|n|d}-shared-{base|restricted}` under corresponding environment's folder and `prj-c-dns-hub` under the folder `fldr-common`.
1. Provisioning of four [VLAN attachments](https://cloud.google.com/network-connectivity/docs/interconnect/concepts/partner-overview) in the Hub project in the specified environment. That would be the `prj-{p|n|d}-shared-{base|restricted}` under corresponding environment's folder and `prj-net-dns` under the folder `fldr-common`.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion 3-networks-dual-svpc/modules/restricted_shared_vpc/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ resource "google_dns_policy" "default_policy" {
Creates DNS Peering to DNS HUB
*****************************************/
data "google_compute_network" "vpc_dns_hub" {
name = "vpc-c-dns-hub"
name = "vpc-net-dns"
project = var.dns_hub_project_id
}

Expand Down
16 changes: 8 additions & 8 deletions 3-networks-hub-and-spoke/envs/shared/dns-hub.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ module "dns_hub_vpc" {
version = "~> 9.0"

project_id = local.dns_hub_project_id
network_name = "vpc-c-dns-hub"
network_name = "vpc-net-dns"
shared_vpc_host = "false"
delete_default_internet_gateway_routes = "true"

subnets = [{
subnet_name = "sb-c-dns-hub-${local.default_region1}"
subnet_name = "sb-net-dns-${local.default_region1}"
subnet_ip = "172.16.0.0/25"
subnet_region = local.default_region1
subnet_private_access = "true"
Expand All @@ -40,7 +40,7 @@ module "dns_hub_vpc" {
subnet_flow_logs_filter = var.dns_vpc_flow_logs.filter_expr
description = "DNS hub subnet for region 1."
}, {
subnet_name = "sb-c-dns-hub-${local.default_region2}"
subnet_name = "sb-net-dns-${local.default_region2}"
subnet_ip = "172.16.0.128/25"
subnet_region = local.default_region2
subnet_private_access = "true"
Expand All @@ -54,7 +54,7 @@ module "dns_hub_vpc" {
}]

routes = [{
name = "rt-c-dns-hub-1000-all-default-private-api"
name = "rt-net-dns-1000-all-default-private-api"
description = "Route through IGW to allow private google api access."
destination_range = "199.36.153.8/30"
next_hop_internet = "true"
Expand Down Expand Up @@ -103,7 +103,7 @@ module "dns_hub_region1_router1" {
source = "terraform-google-modules/cloud-router/google"
version = "~> 6.0"

name = "cr-c-dns-hub-${local.default_region1}-cr1"
name = "cr-net-dns-${local.default_region1}-cr1"
project = local.dns_hub_project_id
network = module.dns_hub_vpc.network_name
region = local.default_region1
Expand All @@ -117,7 +117,7 @@ module "dns_hub_region1_router2" {
source = "terraform-google-modules/cloud-router/google"
version = "~> 6.0"

name = "cr-c-dns-hub-${local.default_region1}-cr2"
name = "cr-net-dns-${local.default_region1}-cr2"
project = local.dns_hub_project_id
network = module.dns_hub_vpc.network_name
region = local.default_region1
Expand All @@ -131,7 +131,7 @@ module "dns_hub_region2_router1" {
source = "terraform-google-modules/cloud-router/google"
version = "~> 6.0"

name = "cr-c-dns-hub-${local.default_region2}-cr3"
name = "cr-net-dns-${local.default_region2}-cr3"
project = local.dns_hub_project_id
network = module.dns_hub_vpc.network_name
region = local.default_region2
Expand All @@ -145,7 +145,7 @@ module "dns_hub_region2_router2" {
source = "terraform-google-modules/cloud-router/google"
version = "~> 6.0"

name = "cr-c-dns-hub-${local.default_region2}-cr4"
name = "cr-net-dns-${local.default_region2}-cr4"
project = local.dns_hub_project_id
network = module.dns_hub_vpc.network_name
region = local.default_region2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
module "dns_hub_interconnect" {
source = "../../modules/dedicated_interconnect"

vpc_name = "c-dns-hub"
vpc_name = "net-dns"
interconnect_project_id = local.dns_hub_project_id

region1 = local.default_region1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
module "dns_hub_interconnect" {
source = "../../modules/partner_interconnect"

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

Expand Down
2 changes: 1 addition & 1 deletion 3-networks-hub-and-spoke/modules/base_shared_vpc/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ resource "google_dns_policy" "default_policy" {
Creates DNS Peering to DNS HUB
*****************************************/
data "google_compute_network" "vpc_dns_hub" {
name = "vpc-c-dns-hub"
name = "vpc-net-dns"
project = var.dns_hub_project_id
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This module implements the recommendation proposed in [Establishing 99.99% Avail

## Prerequisites

1. Provisioning of four [VLAN attachments](https://cloud.google.com/network-connectivity/docs/interconnect/concepts/partner-overview) in the Hub project in the specified environment. That would be the `prj-c-{base|restricted}-net-hub` and `prj-c-dns-hub` under the folder `fldr-common` in case of Hub and Spoke architecture.
1. Provisioning of four [VLAN attachments](https://cloud.google.com/network-connectivity/docs/interconnect/concepts/partner-overview) in the Hub project in the specified environment. That would be the `prj-c-{base|restricted}-net-hub` and `prj-net-dns` under the folder `fldr-common` in case of Hub and Spoke architecture.

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ resource "google_dns_policy" "default_policy" {
Creates DNS Peering to DNS HUB
*****************************************/
data "google_compute_network" "vpc_dns_hub" {
name = "vpc-c-dns-hub"
name = "vpc-net-dns"
project = var.dns_hub_project_id
}

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ example-organization
├── prj-c-kms
└── prj-c-secrets
└── fldr-network
├── prj-c-base-net-hub
├── prj-c-dns-hub
├── prj-c-interconnect
├── prj-c-restricted-net-hub
├── prj-net-hub-base
├── prj-net-hub-restricted
├── prj-net-dns
├── prj-net-interconnect
├── prj-d-shared-base
├── prj-d-shared-restricted
├── prj-n-shared-base
Expand Down Expand Up @@ -264,10 +264,10 @@ example-organization
├── prj-c-bu1-infra-pipeline
└── prj-c-bu2-infra-pipeline
└── fldr-network
├── prj-c-base-net-hub
├── prj-c-dns-hub
├── prj-c-interconnect
├── prj-c-restricted-net-hub
├── prj-net-hub-base
├── prj-net-hub-restricted
├── prj-net-dns
├── prj-net-interconnect
├── prj-d-shared-base
├── prj-d-shared-restricted
├── prj-n-shared-base
Expand Down
8 changes: 4 additions & 4 deletions docs/upgrading_to_v4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Before moving forward with adopting components of v4, review the list of breakin
- A new Network folder was created be used as parent by network projects:
- `prj-ENV-shared-base`
- `prj-ENV-shared-restricted`
- `prj-c-base-net-hub`
- `prj-c-restricted-net-hub`
- `prj-c-dns-hub`
- `prj-c-interconnect`
- `prj-net-hub-base`
- `prj-net-hub-restricted`
- `prj-net-dns`
- `prj-net-interconnect`
- Network Refactoring
- Network projects are now created under a new folder `network`
- VPC firewall rules (`google_compute_firewall`) resources were replaced with Compute Network firewall policy (`google_compute_network_firewall_policy`) resources
Expand Down
18 changes: 9 additions & 9 deletions test/integration/shared/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func TestShared(t *testing.T) {
// shared.DefaultVerify(assert)

projectID := shared.GetStringOutput("dns_hub_project_id")
networkName := "vpc-c-dns-hub"
dnsHubNetworkUrl := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/global/networks/vpc-c-dns-hub", projectID)
networkName := "vpc-net-dns"
dnsHubNetworkUrl := fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/global/networks/vpc-net-dns", projectID)
dnsPolicyName := "dp-dns-hub-default-policy"

dnsPolicy := gcloud.Runf(t, "dns policies describe %s --project %s", dnsPolicyName, projectID)
Expand All @@ -109,12 +109,12 @@ func TestShared(t *testing.T) {
region string
}{
{
name: "sb-c-dns-hub-us-central1",
name: "sb-net-dns-us-central1",
cidrRange: "172.16.0.128/25",
region: "us-central1",
},
{
name: "sb-c-dns-hub-us-west1",
name: "sb-net-dns-us-west1",
cidrRange: "172.16.0.0/25",
region: "us-west1",
},
Expand All @@ -131,19 +131,19 @@ func TestShared(t *testing.T) {
region string
}{
{
name: "cr-c-dns-hub-us-west1-cr1",
name: "cr-net-dns-us-west1-cr1",
region: "us-west1",
},
{
name: "cr-c-dns-hub-us-west1-cr2",
name: "cr-net-dns-us-west1-cr2",
region: "us-west1",
},
{
name: "cr-c-dns-hub-us-central1-cr3",
name: "cr-net-dns-us-central1-cr3",
region: "us-central1",
},
{
name: "cr-c-dns-hub-us-central1-cr4",
name: "cr-net-dns-us-central1-cr4",
region: "us-central1",
},
} {
Expand All @@ -152,7 +152,7 @@ func TestShared(t *testing.T) {
assert.Equal("64667", computeRouter.Get("bgp.asn").String(), fmt.Sprintf("router %s should have bgp asm 64667", router.name))
assert.Equal(1, len(computeRouter.Get("bgp.advertisedIpRanges").Array()), fmt.Sprintf("router %s should have only one advertised IP range", router.name))
assert.Equal(bgpAdvertisedIpRange, computeRouter.Get("bgp.advertisedIpRanges.0.range").String(), fmt.Sprintf("router %s should have only range %s", router.name, bgpAdvertisedIpRange))
assert.Equal(dnsHubNetworkUrl, computeRouter.Get("network").String(), fmt.Sprintf("router %s should have be from network vpc-c-dns-hub", router.name))
assert.Equal(dnsHubNetworkUrl, computeRouter.Get("network").String(), fmt.Sprintf("router %s should have be from network vpc-net-dns", router.name))
}
})
shared.Test()
Expand Down

0 comments on commit 1822e42

Please sign in to comment.