diff --git a/0-bootstrap/README-Jenkins.md b/0-bootstrap/README-Jenkins.md index 5ece83a8f..b1bd39a07 100644 --- a/0-bootstrap/README-Jenkins.md +++ b/0-bootstrap/README-Jenkins.md @@ -546,9 +546,9 @@ Here you will configure a VPN Network tunnel to enable connectivity between the ``` 1. Review the apply output in your Controller's web UI (you might want to use the option to "Scan Multibranch Pipeline Now" in your Jenkins Controller UI). -1. You can now move to the instructions in the next step, go to [Deploying step 3-networks-dual-svpc](#deploying-step-3-networks-dual-svpc) to use the Dual Shared VPC mode, or go to [Deploying step 3-networks-hub-and-spoke](#deploying-step-3-networks-hub-and-spoke) to use the Hub and Spoke network mode. +1. You can now move to the instructions in the next step, go to [Deploying step 3-networks-svpc](#deploying-step-3-networks-svpc) to use the Dual Shared VPC mode, or go to [Deploying step 3-networks-hub-and-spoke](#deploying-step-3-networks-hub-and-spoke) to use the Hub and Spoke network mode. -## Deploying step 3-networks-dual-svpc +## Deploying step 3-networks-svpc 1. Clone the repo you created manually in 0-bootstrap. @@ -568,7 +568,7 @@ Here you will configure a VPN Network tunnel to enable connectivity between the 1. Copy contents of foundation to new repo. ```bash - cp -RT ../terraform-example-foundation/3-networks-dual-svpc/ . + cp -RT ../terraform-example-foundation/3-networks-svpc/ . cp -RT ../terraform-example-foundation/policy-library/ ./policy-library cp ../terraform-example-foundation/build/Jenkinsfile . cp ../terraform-example-foundation/build/tf-wrapper.sh . @@ -607,7 +607,7 @@ Here you will configure a VPN Network tunnel to enable connectivity between the mv access_context.auto.example.tfvars access_context.auto.tfvars ``` -1. Update `common.auto.tfvars` file with values from your environment and bootstrap. See any of the envs folder [README.md](../3-networks-dual-svpc/envs/production/README.md) files for additional information on the values in the `common.auto.tfvars` file. +1. Update `common.auto.tfvars` file with values from your environment and bootstrap. See any of the envs folder [README.md](../3-networks-svpc/envs/production/README.md) files for additional information on the values in the `common.auto.tfvars` file. 1. Update `production.auto.tfvars` file with the `target_name_server_addresses`. 1. Update `access_context.auto.tfvars` file with the `access_context_manager_policy_id`. 1. Use `terraform output` to get the backend bucket and networks step Terraform Service Account values from gcp-bootstrap output. diff --git a/0-bootstrap/README-Terraform-Cloud.md b/0-bootstrap/README-Terraform-Cloud.md index 3956776c5..53b17c734 100644 --- a/0-bootstrap/README-Terraform-Cloud.md +++ b/0-bootstrap/README-Terraform-Cloud.md @@ -213,7 +213,7 @@ export the OAuth Token ID as an environment variable: 1. Run `terraform plan -input=false -out bootstrap_2.tfplan` 1. Run `terraform apply bootstrap_2.tfplan` -1. Run `terraform output` to get the email address of the terraform service accounts that will be used to run manual steps for `shared` environments in steps `3-networks-dual-svpc`, `3-networks-hub-and-spoke`, and `4-projects`. +1. Run `terraform output` to get the email address of the terraform service accounts that will be used to run manual steps for `shared` environments in steps `3-networks-svpc`, `3-networks-hub-and-spoke`, and `4-projects`. ```bash export network_step_sa=$(terraform output -raw networks_step_terraform_service_account_email) @@ -230,7 +230,7 @@ export the OAuth Token ID as an environment variable: echo "CI/CD Project ID = ${cicd_project_id}" ``` -1. Run `terraform output` to get the name of the TFC organization and export it as environment variables. `TF_CLOUD_ORGANIZATION` variable will be used by the `cloud` block in order to move the local Terraform's state to TFC and `TF_VAR_tfc_org_name` will be used to run manual steps for `shared` environments in steps `3-networks-dual-svpc`, `3-networks-hub-and-spoke`, and `4-projects` +1. Run `terraform output` to get the name of the TFC organization and export it as environment variables. `TF_CLOUD_ORGANIZATION` variable will be used by the `cloud` block in order to move the local Terraform's state to TFC and `TF_VAR_tfc_org_name` will be used to run manual steps for `shared` environments in steps `3-networks-svpc`, `3-networks-hub-and-spoke`, and `4-projects` ```bash export TF_CLOUD_ORGANIZATION=$(terraform output -raw tfc_org_name) @@ -441,7 +441,7 @@ See any of the envs folder [README.md](../2-environments/envs/production/README. 1. Review apply output in Terraform Cloud https://app.terraform.io/app/TFC-ORGANIZATION-NAME/workspaces/2-production/runs under `Run List` item. 1. You can now move to the instructions in the network stage. -To use the [Dual Shared VPC](https://cloud.google.com/architecture/security-foundations/networking#vpcsharedvpc-id7-1-shared-vpc-) network mode go to [Deploying step 3-networks-dual-svpc](#deploying-step-3-networks-dual-svpc), +To use the [Dual Shared VPC](https://cloud.google.com/architecture/security-foundations/networking#vpcsharedvpc-id7-1-shared-vpc-) network mode go to [Deploying step 3-networks-svpc](#deploying-step-3-networks-svpc), or go to [Deploying step 3-networks-hub-and-spoke](#deploying-step-3-networks-hub-and-spoke) to use the [Hub and Spoke](https://cloud.google.com/architecture/security-foundations/networking#hub-and-spoke) network mode. 1. Before moving to the next step, go back to the parent directory. @@ -450,7 +450,7 @@ or go to [Deploying step 3-networks-hub-and-spoke](#deploying-step-3-networks-hu cd .. ``` -## Deploying step 3-networks-dual-svpc +## Deploying step 3-networks-svpc **Note:** For all purposes we treat `shared` environment as `production` environment due to the possible impacts into `production`. So `3-production` TFC workspace have a [Run Trigger](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/settings/run-triggers) sourcing `3-shared` TFC workspace, which means that every time you successfully run an apply job in `3-shared` TFC workspace, a `Plan and apply` job will be triggered automatically for `3-production` TFC workspace. (All the applies will continue requiring manual approvals in TFC console). @@ -470,7 +470,7 @@ or go to [Deploying step 3-networks-hub-and-spoke](#deploying-step-3-networks-hu 1. Copy contents of foundation to new repo. ```bash - cp -RT ../terraform-example-foundation/3-networks-dual-svpc/ . + cp -RT ../terraform-example-foundation/3-networks-svpc/ . cp -RT ../terraform-example-foundation/policy-library/ ./policy-library cp ../terraform-example-foundation/build/tf-wrapper.sh . chmod 755 ./tf-wrapper.sh @@ -498,8 +498,8 @@ or go to [Deploying step 3-networks-hub-and-spoke](#deploying-step-3-networks-hu ``` 1. Update `common.auto.tfvars` file with values from your GCP environment. -See any of the envs folder [README.md](../3-networks-dual-svpc/envs/production/README.md#inputs) files for additional information on the values in the `common.auto.tfvars` file. -1. You must add your user email in the variable `perimeter_additional_members` to be able to see the resources created in the restricted project. +See any of the envs folder [README.md](../3-networks-svpc/envs/production/README.md#inputs) files for additional information on the values in the `common.auto.tfvars` file. +1. You must add your user email in the variable `perimeter_additional_members` to be able to see the resources created in the project. 1. You must manually plan and apply the `shared` environment from your (only once) since the `development`, `nonproduction` and `production` environments depend on it. @@ -649,7 +649,7 @@ An environment variable `GOOGLE_IMPERSONATE_SERVICE_ACCOUNT` will be set with th 1. Update `common.auto.tfvars` file with values from your GCP environment. See any of the envs folder [README.md](../3-networks-hub-and-spoke/envs/production/README.md#inputs) files for additional information on the values in the `common.auto.tfvars` file. -1. You must add your user email in the variable `perimeter_additional_members` to be able to see the resources created in the restricted project. +1. You must add your user email in the variable `perimeter_additional_members` to be able to see the resources created in the project. 1. You must manually plan and apply the `shared` environment (only once) since the `development`, `nonproduction` and `production` environments depend on it. diff --git a/0-bootstrap/README.md b/0-bootstrap/README.md index afc92af12..15a339411 100644 --- a/0-bootstrap/README.md +++ b/0-bootstrap/README.md @@ -25,16 +25,16 @@ organizational policy. Google Cloud organization that you've created.
object({
is_locked = bool
retention_period_days = number
}) | `null` | no |
| log\_export\_storage\_versioning | (Optional) Toggles bucket versioning, ability to retain a non-current object version when the live object version gets replaced or deleted. | `bool` | `false` | no |
-| project\_budget | Budget configuration for projects.object({
base_net_hub_budget_amount = optional(number, 1000)
base_net_hub_alert_spent_percents = optional(list(number), [1.2])
base_net_hub_alert_pubsub_topic = optional(string, null)
base_net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
base_network_budget_amount = optional(number, 1000)
base_network_alert_spent_percents = optional(list(number), [1.2])
base_network_alert_pubsub_topic = optional(string, null)
base_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
restricted_net_hub_budget_amount = optional(number, 1000)
restricted_net_hub_alert_spent_percents = optional(list(number), [1.2])
restricted_net_hub_alert_pubsub_topic = optional(string, null)
restricted_net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
restricted_network_budget_amount = optional(number, 1000)
restricted_network_alert_spent_percents = optional(list(number), [1.2])
restricted_network_alert_pubsub_topic = optional(string, null)
restricted_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
interconnect_budget_amount = optional(number, 1000)
interconnect_alert_spent_percents = optional(list(number), [1.2])
interconnect_alert_pubsub_topic = optional(string, null)
interconnect_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
org_secrets_budget_amount = optional(number, 1000)
org_secrets_alert_spent_percents = optional(list(number), [1.2])
org_secrets_alert_pubsub_topic = optional(string, null)
org_secrets_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
org_billing_export_budget_amount = optional(number, 1000)
org_billing_export_alert_spent_percents = optional(list(number), [1.2])
org_billing_export_alert_pubsub_topic = optional(string, null)
org_billing_export_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
org_audit_logs_budget_amount = optional(number, 1000)
org_audit_logs_alert_spent_percents = optional(list(number), [1.2])
org_audit_logs_alert_pubsub_topic = optional(string, null)
org_audit_logs_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
common_kms_budget_amount = optional(number, 1000)
common_kms_alert_spent_percents = optional(list(number), [1.2])
common_kms_alert_pubsub_topic = optional(string, null)
common_kms_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
scc_notifications_budget_amount = optional(number, 1000)
scc_notifications_alert_spent_percents = optional(list(number), [1.2])
scc_notifications_alert_pubsub_topic = optional(string, null)
scc_notifications_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
}) | `{}` | no |
+| project\_budget | Budget configuration for projects.object({
net_hub_budget_amount = optional(number, 1000)
net_hub_alert_spent_percents = optional(list(number), [1.2])
net_hub_alert_pubsub_topic = optional(string, null)
net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
shared_network_budget_amount = optional(number, 1000)
shared_network_alert_spent_percents = optional(list(number), [1.2])
shared_network_alert_pubsub_topic = optional(string, null)
shared_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
interconnect_budget_amount = optional(number, 1000)
interconnect_alert_spent_percents = optional(list(number), [1.2])
interconnect_alert_pubsub_topic = optional(string, null)
interconnect_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
org_secrets_budget_amount = optional(number, 1000)
org_secrets_alert_spent_percents = optional(list(number), [1.2])
org_secrets_alert_pubsub_topic = optional(string, null)
org_secrets_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
org_billing_export_budget_amount = optional(number, 1000)
org_billing_export_alert_spent_percents = optional(list(number), [1.2])
org_billing_export_alert_pubsub_topic = optional(string, null)
org_billing_export_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
org_audit_logs_budget_amount = optional(number, 1000)
org_audit_logs_alert_spent_percents = optional(list(number), [1.2])
org_audit_logs_alert_pubsub_topic = optional(string, null)
org_audit_logs_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
common_kms_budget_amount = optional(number, 1000)
common_kms_alert_spent_percents = optional(list(number), [1.2])
common_kms_alert_pubsub_topic = optional(string, null)
common_kms_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
scc_notifications_budget_amount = optional(number, 1000)
scc_notifications_alert_spent_percents = optional(list(number), [1.2])
scc_notifications_alert_pubsub_topic = optional(string, null)
scc_notifications_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
}) | `{}` | no |
| project\_deletion\_policy | The deletion policy for the project created. | `string` | `"PREVENT"` | no |
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes |
| scc\_notification\_filter | Filter used to create the Security Command Center Notification, you can see more details on how to create filters in https://cloud.google.com/security-command-center/docs/how-to-api-filter-notifications#create-filter | `string` | `"state = \"ACTIVE\""` | no |
@@ -29,7 +29,6 @@
| Name | Description |
|------|-------------|
-| base\_net\_hub\_project\_id | The Base Network hub project ID |
| billing\_sink\_names | The name of the sinks under billing account level. |
| cai\_monitoring\_artifact\_registry | CAI Monitoring Cloud Function Artifact Registry name. |
| cai\_monitoring\_asset\_feed | CAI Monitoring Cloud Function Organization Asset Feed name. |
@@ -44,6 +43,8 @@
| logs\_export\_project\_logbucket\_name | The resource name for the Log Bucket created for the project destination. |
| logs\_export\_pubsub\_topic | The Pub/Sub topic for destination of log exports |
| logs\_export\_storage\_bucket\_name | The storage bucket for destination of log exports |
+| net\_hub\_project\_id | The Network hub project ID |
+| net\_hub\_project\_number | The Network hub project number |
| network\_folder\_name | The network folder name. |
| org\_audit\_logs\_project\_id | The org audit logs project ID. |
| org\_billing\_export\_project\_id | The org billing export project ID |
@@ -51,11 +52,9 @@
| org\_secrets\_project\_id | The org secrets project ID |
| parent\_resource\_id | The parent resource id |
| parent\_resource\_type | The parent resource type |
-| restricted\_net\_hub\_project\_id | The Restricted Network hub project ID |
-| restricted\_net\_hub\_project\_number | The Restricted Network hub project number |
| scc\_notification\_name | Name of SCC Notification |
| scc\_notifications\_project\_id | The SCC notifications project ID |
-| shared\_vpc\_projects | Base and restricted shared VPC Projects info grouped by environment (development, nonproduction, production). |
+| shared\_vpc\_projects | Shared VPC Projects info grouped by environment (development, nonproduction, production). |
| tags | Tag Values to be applied on next steps. |
diff --git a/1-org/envs/shared/outputs.tf b/1-org/envs/shared/outputs.tf
index 5d7d1c986..df9e55da2 100644
--- a/1-org/envs/shared/outputs.tf
+++ b/1-org/envs/shared/outputs.tf
@@ -79,19 +79,14 @@ output "scc_notifications_project_id" {
description = "The SCC notifications project ID"
}
-output "base_net_hub_project_id" {
- value = try(module.base_network_hub[0].project_id, null)
- description = "The Base Network hub project ID"
+output "net_hub_project_id" {
+ value = try(module.network_hub[0].project_id, null)
+ description = "The Network hub project ID"
}
-output "restricted_net_hub_project_id" {
- value = try(module.restricted_network_hub[0].project_id, null)
- description = "The Restricted Network hub project ID"
-}
-
-output "restricted_net_hub_project_number" {
- value = try(module.restricted_network_hub[0].project_number, null)
- description = "The Restricted Network hub project number"
+output "net_hub_project_number" {
+ value = try(module.network_hub[0].project_number, null)
+ description = "The Network hub project number"
}
output "domains_to_allow" {
@@ -130,8 +125,8 @@ output "tags" {
}
output "shared_vpc_projects" {
- value = { for k, v in module.base_restricted_environment_network : k => v }
- description = "Base and restricted shared VPC Projects info grouped by environment (development, nonproduction, production)."
+ value = { for k, v in module.environment_network : k => v }
+ description = "Shared VPC Projects info grouped by environment (development, nonproduction, production)."
}
output "cai_monitoring_artifact_registry" {
diff --git a/1-org/envs/shared/projects.tf b/1-org/envs/shared/projects.tf
index 5ae87ac57..5798fa6b1 100644
--- a/1-org/envs/shared/projects.tf
+++ b/1-org/envs/shared/projects.tf
@@ -234,10 +234,10 @@ module "scc_notifications" {
}
/******************************************
- Project for Base Network Hub
+ Project for Network Hub
*****************************************/
-module "base_network_hub" {
+module "network_hub" {
source = "terraform-google-modules/project-factory/google"
version = "~> 18.0"
count = var.enable_hub_and_spoke ? 1 : 0
@@ -245,7 +245,7 @@ module "base_network_hub" {
random_project_id = true
random_project_id_length = 4
default_service_account = "deprivilege"
- name = "${local.project_prefix}-net-hub-base"
+ name = "${local.project_prefix}-net-hub"
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.network.id
@@ -262,76 +262,25 @@ module "base_network_hub" {
labels = {
environment = "network"
- application_name = "org-net-hub-base"
+ application_name = "org-net-hub"
billing_code = "1234"
primary_contact = "example1"
secondary_contact = "example2"
business_code = "shared"
env_code = "net"
- vpc = "base"
+ vpc = "svpc"
}
- budget_alert_pubsub_topic = var.project_budget.base_net_hub_alert_pubsub_topic
- budget_alert_spent_percents = var.project_budget.base_net_hub_alert_spent_percents
- budget_amount = var.project_budget.base_net_hub_budget_amount
- budget_alert_spend_basis = var.project_budget.base_net_hub_budget_alert_spend_basis
-}
-
-resource "google_project_iam_member" "network_sa_base" {
- for_each = toset(var.enable_hub_and_spoke ? local.hub_and_spoke_roles : [])
-
- project = module.base_network_hub[0].project_id
- role = each.key
- member = "serviceAccount:${local.networks_step_terraform_service_account_email}"
-}
-
-/******************************************
- Project for Restricted Network Hub
-*****************************************/
-
-module "restricted_network_hub" {
- source = "terraform-google-modules/project-factory/google"
- version = "~> 18.0"
- count = var.enable_hub_and_spoke ? 1 : 0
-
- random_project_id = true
- random_project_id_length = 4
- default_service_account = "deprivilege"
- name = "${local.project_prefix}-net-hub-restricted"
- org_id = local.org_id
- billing_account = local.billing_account
- folder_id = google_folder.network.id
- deletion_policy = var.project_deletion_policy
-
- activate_apis = [
- "compute.googleapis.com",
- "dns.googleapis.com",
- "servicenetworking.googleapis.com",
- "logging.googleapis.com",
- "cloudresourcemanager.googleapis.com",
- "billingbudgets.googleapis.com"
- ]
-
- labels = {
- environment = "network"
- application_name = "org-net-hub-restricted"
- billing_code = "1234"
- primary_contact = "example1"
- secondary_contact = "example2"
- business_code = "shared"
- env_code = "net"
- vpc = "restricted"
- }
- budget_alert_pubsub_topic = var.project_budget.restricted_net_hub_alert_pubsub_topic
- budget_alert_spent_percents = var.project_budget.restricted_net_hub_alert_spent_percents
- budget_amount = var.project_budget.restricted_net_hub_budget_amount
- budget_alert_spend_basis = var.project_budget.restricted_net_hub_budget_alert_spend_basis
+ budget_alert_pubsub_topic = var.project_budget.net_hub_alert_pubsub_topic
+ budget_alert_spent_percents = var.project_budget.net_hub_alert_spent_percents
+ budget_amount = var.project_budget.net_hub_budget_amount
+ budget_alert_spend_basis = var.project_budget.net_hub_budget_alert_spend_basis
}
/************************************************************
- Base and Restricted Network Projects for each Environment
+Network Project for each Environment
************************************************************/
-module "base_restricted_environment_network" {
+module "environment_network" {
source = "../../modules/network"
for_each = local.environments
@@ -346,14 +295,10 @@ module "base_restricted_environment_network" {
env_code = each.value
project_budget = {
- base_network_budget_amount = var.project_budget.base_network_budget_amount
- base_network_alert_spent_percents = var.project_budget.base_network_alert_spent_percents
- base_network_alert_pubsub_topic = var.project_budget.base_network_alert_pubsub_topic
- base_network_budget_alert_spend_basis = var.project_budget.base_network_budget_alert_spend_basis
- restricted_network_budget_amount = var.project_budget.restricted_network_budget_amount
- restricted_network_alert_spent_percents = var.project_budget.restricted_network_alert_spent_percents
- restricted_network_alert_pubsub_topic = var.project_budget.restricted_network_alert_pubsub_topic
- restricted_network_budget_alert_spend_basis = var.project_budget.restricted_network_budget_alert_spend_basis
+ network_budget_amount = var.project_budget.shared_network_budget_amount
+ network_alert_spent_percents = var.project_budget.shared_network_alert_spent_percents
+ network_alert_pubsub_topic = var.project_budget.shared_network_alert_pubsub_topic
+ network_budget_alert_spend_basis = var.project_budget.shared_network_budget_alert_spend_basis
}
}
@@ -361,10 +306,10 @@ module "base_restricted_environment_network" {
Roles granted to the networks SA for Hub and Spoke network topology
*********************************************************************/
-resource "google_project_iam_member" "network_sa_restricted" {
+resource "google_project_iam_member" "network_sa" {
for_each = toset(var.enable_hub_and_spoke ? local.hub_and_spoke_roles : [])
- project = module.restricted_network_hub[0].project_id
+ project = module.network_hub[0].project_id
role = each.key
member = "serviceAccount:${local.networks_step_terraform_service_account_email}"
}
diff --git a/1-org/envs/shared/variables.tf b/1-org/envs/shared/variables.tf
index 929d213df..bc6fae1cf 100644
--- a/1-org/envs/shared/variables.tf
+++ b/1-org/envs/shared/variables.tf
@@ -97,22 +97,14 @@ variable "project_budget" {
alert_spend_basis: The type of basis used to determine if spend has passed the threshold. Possible choices are `CURRENT_SPEND` or `FORECASTED_SPEND` (default).
EOT
type = object({
- base_net_hub_budget_amount = optional(number, 1000)
- base_net_hub_alert_spent_percents = optional(list(number), [1.2])
- base_net_hub_alert_pubsub_topic = optional(string, null)
- base_net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
- base_network_budget_amount = optional(number, 1000)
- base_network_alert_spent_percents = optional(list(number), [1.2])
- base_network_alert_pubsub_topic = optional(string, null)
- base_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
- restricted_net_hub_budget_amount = optional(number, 1000)
- restricted_net_hub_alert_spent_percents = optional(list(number), [1.2])
- restricted_net_hub_alert_pubsub_topic = optional(string, null)
- restricted_net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
- restricted_network_budget_amount = optional(number, 1000)
- restricted_network_alert_spent_percents = optional(list(number), [1.2])
- restricted_network_alert_pubsub_topic = optional(string, null)
- restricted_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
+ net_hub_budget_amount = optional(number, 1000)
+ net_hub_alert_spent_percents = optional(list(number), [1.2])
+ net_hub_alert_pubsub_topic = optional(string, null)
+ net_hub_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
+ shared_network_budget_amount = optional(number, 1000)
+ shared_network_alert_spent_percents = optional(list(number), [1.2])
+ shared_network_alert_pubsub_topic = optional(string, null)
+ shared_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
interconnect_budget_amount = optional(number, 1000)
interconnect_alert_spent_percents = optional(list(number), [1.2])
interconnect_alert_pubsub_topic = optional(string, null)
diff --git a/1-org/modules/network/main.tf b/1-org/modules/network/main.tf
index 7e3ac03d4..4f6e566d8 100644
--- a/1-org/modules/network/main.tf
+++ b/1-org/modules/network/main.tf
@@ -18,50 +18,13 @@
Projects for Shared VPCs
*****************************************/
-module "base_shared_vpc_host_project" {
+module "shared_vpc_host_project" {
source = "terraform-google-modules/project-factory/google"
version = "~> 18.0"
random_project_id = true
random_project_id_length = 4
- name = format("%s-%s-shared-base", var.project_prefix, var.env_code)
- org_id = var.org_id
- billing_account = var.billing_account
- folder_id = var.folder_id
- disable_services_on_destroy = false
- deletion_policy = var.project_deletion_policy
-
- activate_apis = [
- "compute.googleapis.com",
- "dns.googleapis.com",
- "servicenetworking.googleapis.com",
- "container.googleapis.com",
- "logging.googleapis.com",
- "billingbudgets.googleapis.com"
- ]
-
- labels = {
- environment = var.env
- application_name = "base-shared-vpc-host"
- billing_code = "1234"
- primary_contact = "example1"
- secondary_contact = "example2"
- business_code = "shared"
- env_code = var.env_code
- vpc = "base"
- }
- budget_alert_pubsub_topic = var.project_budget.base_network_alert_pubsub_topic
- budget_alert_spent_percents = var.project_budget.base_network_alert_spent_percents
- budget_amount = var.project_budget.base_network_budget_amount
-}
-
-module "restricted_shared_vpc_host_project" {
- source = "terraform-google-modules/project-factory/google"
- version = "~> 18.0"
-
- random_project_id = true
- random_project_id_length = 4
- name = format("%s-%s-shared-restricted", var.project_prefix, var.env_code)
+ name = format("%s-%s-svpc", var.project_prefix, var.env_code)
org_id = var.org_id
billing_account = var.billing_account
folder_id = var.folder_id
@@ -81,16 +44,16 @@ module "restricted_shared_vpc_host_project" {
labels = {
environment = var.env
- application_name = "restricted-shared-vpc-host"
+ application_name = "shared-vpc-host"
billing_code = "1234"
primary_contact = "example1"
secondary_contact = "example2"
business_code = "shared"
env_code = var.env_code
- vpc = "restricted"
}
- budget_alert_pubsub_topic = var.project_budget.restricted_network_alert_pubsub_topic
- budget_alert_spent_percents = var.project_budget.restricted_network_alert_spent_percents
- budget_amount = var.project_budget.restricted_network_budget_amount
- budget_alert_spend_basis = var.project_budget.restricted_network_budget_alert_spend_basis
+
+ budget_alert_pubsub_topic = var.project_budget.shared_network_alert_pubsub_topic
+ budget_alert_spent_percents = var.project_budget.shared_network_alert_spent_percents
+ budget_amount = var.project_budget.shared_network_budget_amount
+ budget_alert_spend_basis = var.project_budget.shared_network_budget_alert_spend_basis
}
diff --git a/1-org/modules/network/outputs.tf b/1-org/modules/network/outputs.tf
index 134e55240..91a08c6a7 100644
--- a/1-org/modules/network/outputs.tf
+++ b/1-org/modules/network/outputs.tf
@@ -14,22 +14,12 @@
* limitations under the License.
*/
-output "base_shared_vpc_project_id" {
- description = "Project id for base shared VPC network."
- value = module.base_shared_vpc_host_project.project_id
+output "shared_vpc_project_id" {
+ description = "Project id for shared VPC network."
+ value = module.shared_vpc_host_project.project_id
}
-output "base_shared_vpc_project_number" {
- description = "Project number for base shared VPC network."
- value = module.base_shared_vpc_host_project.project_number
-}
-
-output "restricted_shared_vpc_project_id" {
- description = "Project id for restricted shared VPC network."
- value = module.restricted_shared_vpc_host_project.project_id
-}
-
-output "restricted_shared_vpc_project_number" {
- description = "Project number for restricted shared VPC."
- value = module.restricted_shared_vpc_host_project.project_number
+output "shared_vpc_project_number" {
+ description = "Project number for shared VPC."
+ value = module.shared_vpc_host_project.project_number
}
diff --git a/1-org/modules/network/variables.tf b/1-org/modules/network/variables.tf
index 32887bad5..c002de92f 100644
--- a/1-org/modules/network/variables.tf
+++ b/1-org/modules/network/variables.tf
@@ -59,14 +59,10 @@ variable "project_budget" {
alert_pubsub_topic: The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}`.
EOT
type = object({
- base_network_budget_amount = optional(number, 1000)
- base_network_alert_spent_percents = optional(list(number), [1.2])
- base_network_alert_pubsub_topic = optional(string, null)
- base_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
- restricted_network_budget_amount = optional(number, 1000)
- restricted_network_alert_spent_percents = optional(list(number), [1.2])
- restricted_network_alert_pubsub_topic = optional(string, null)
- restricted_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
+ shared_network_budget_amount = optional(number, 1000)
+ shared_network_alert_spent_percents = optional(list(number), [1.2])
+ shared_network_alert_pubsub_topic = optional(string, null)
+ shared_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
})
default = {}
}
diff --git a/2-environments/README.md b/2-environments/README.md
index 814b89896..a75598141 100644
--- a/2-environments/README.md
+++ b/2-environments/README.md
@@ -25,16 +25,16 @@ organizational policy.
Google Cloud organization that you've created.
object({
base_network_budget_amount = optional(number, 1000)
base_network_alert_spent_percents = optional(list(number), [1.2])
base_network_alert_pubsub_topic = optional(string, null)
base_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
restricted_network_budget_amount = optional(number, 1000)
restricted_network_alert_spent_percents = optional(list(number), [1.2])
restricted_network_alert_pubsub_topic = optional(string, null)
restricted_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
secret_budget_amount = optional(number, 1000)
secret_alert_spent_percents = optional(list(number), [1.2])
secret_alert_pubsub_topic = optional(string, null)
secret_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
kms_budget_amount = optional(number, 1000)
kms_alert_spent_percents = optional(list(number), [1.2])
kms_alert_pubsub_topic = optional(string, null)
kms_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
}) | `{}` | no |
+| project\_budget | Budget configuration for projects.object({
shared_network_budget_amount = optional(number, 1000)
shared_network_alert_spent_percents = optional(list(number), [1.2])
shared_network_alert_pubsub_topic = optional(string, null)
shared_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
secret_budget_amount = optional(number, 1000)
secret_alert_spent_percents = optional(list(number), [1.2])
secret_alert_pubsub_topic = optional(string, null)
secret_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
kms_budget_amount = optional(number, 1000)
kms_alert_spent_percents = optional(list(number), [1.2])
kms_alert_pubsub_topic = optional(string, null)
kms_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
}) | `{}` | no |
| project\_deletion\_policy | The deletion policy for the project created. | `string` | `"PREVENT"` | no |
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes |
| tfc\_org\_name | Name of the TFC organization | `string` | n/a | yes |
@@ -20,6 +20,7 @@
| assured\_workload\_resources | Resources associated with the Assured Workload. |
| env\_folder | Environment folder created under parent. |
| env\_kms\_project\_id | Project for environment Cloud Key Management Service (KMS). |
+| env\_kms\_project\_number | Project number for envinronment Cloud Key Management Service (KMS). |
| env\_secrets\_project\_id | Project for environment secrets. |
diff --git a/2-environments/modules/env_baseline/outputs.tf b/2-environments/modules/env_baseline/outputs.tf
index 15cd2524f..b949becb9 100644
--- a/2-environments/modules/env_baseline/outputs.tf
+++ b/2-environments/modules/env_baseline/outputs.tf
@@ -29,6 +29,10 @@ output "env_kms_project_id" {
value = module.env_kms.project_id
}
+output "env_kms_project_number" {
+ description = "Project number for envinronment Cloud Key Management Service (KMS)."
+ value = module.env_kms.project_number
+}
output "assured_workload_id" {
description = "Assured Workload ID."
diff --git a/2-environments/modules/env_baseline/variables.tf b/2-environments/modules/env_baseline/variables.tf
index 81ab12a83..813708746 100644
--- a/2-environments/modules/env_baseline/variables.tf
+++ b/2-environments/modules/env_baseline/variables.tf
@@ -43,22 +43,18 @@ variable "project_budget" {
alert_spend_basis: The type of basis used to determine if spend has passed the threshold. Possible choices are `CURRENT_SPEND` or `FORECASTED_SPEND` (default).
EOT
type = object({
- base_network_budget_amount = optional(number, 1000)
- base_network_alert_spent_percents = optional(list(number), [1.2])
- base_network_alert_pubsub_topic = optional(string, null)
- base_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
- restricted_network_budget_amount = optional(number, 1000)
- restricted_network_alert_spent_percents = optional(list(number), [1.2])
- restricted_network_alert_pubsub_topic = optional(string, null)
- restricted_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
- secret_budget_amount = optional(number, 1000)
- secret_alert_spent_percents = optional(list(number), [1.2])
- secret_alert_pubsub_topic = optional(string, null)
- secret_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
- kms_budget_amount = optional(number, 1000)
- kms_alert_spent_percents = optional(list(number), [1.2])
- kms_alert_pubsub_topic = optional(string, null)
- kms_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
+ shared_network_budget_amount = optional(number, 1000)
+ shared_network_alert_spent_percents = optional(list(number), [1.2])
+ shared_network_alert_pubsub_topic = optional(string, null)
+ shared_network_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
+ secret_budget_amount = optional(number, 1000)
+ secret_alert_spent_percents = optional(list(number), [1.2])
+ secret_alert_pubsub_topic = optional(string, null)
+ secret_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
+ kms_budget_amount = optional(number, 1000)
+ kms_alert_spent_percents = optional(list(number), [1.2])
+ kms_alert_pubsub_topic = optional(string, null)
+ kms_budget_alert_spend_basis = optional(string, "FORECASTED_SPEND")
})
default = {}
}
diff --git a/3-networks-dual-svpc/envs/development/main.tf b/3-networks-dual-svpc/envs/development/main.tf
deleted file mode 100644
index 202dc8345..000000000
--- a/3-networks-dual-svpc/envs/development/main.tf
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-locals {
- env = "development"
- environment_code = substr(local.env, 0, 1)
- /*
- * Base network ranges
- */
- base_private_service_cidr = "10.16.8.0/21"
- base_subnet_primary_ranges = {
- (local.default_region1) = "10.0.64.0/18"
- (local.default_region2) = "10.1.64.0/18"
- }
- base_subnet_proxy_ranges = {
- (local.default_region1) = "10.18.2.0/23"
- (local.default_region2) = "10.19.2.0/23"
- }
- base_subnet_secondary_ranges = {
- (local.default_region1) = [
- {
- range_name = "rn-${local.environment_code}-shared-base-${local.default_region1}-gke-pod"
- ip_cidr_range = "100.64.64.0/18"
- },
- {
- range_name = "rn-${local.environment_code}-shared-base-${local.default_region1}-gke-svc"
- ip_cidr_range = "100.65.64.0/18"
- }
- ]
- }
- /*
- * Restricted network ranges
- */
- restricted_private_service_cidr = "10.16.40.0/21"
- restricted_subnet_primary_ranges = {
- (local.default_region1) = "10.8.64.0/18"
- (local.default_region2) = "10.9.64.0/18"
- }
- restricted_subnet_proxy_ranges = {
- (local.default_region1) = "10.26.2.0/23"
- (local.default_region2) = "10.27.2.0/23"
- }
- restricted_subnet_secondary_ranges = {
- (local.default_region1) = [
- {
- range_name = "rn-${local.environment_code}-shared-restricted-${local.default_region1}-gke-pod"
- ip_cidr_range = "100.72.64.0/18"
- },
- {
- range_name = "rn-${local.environment_code}-shared-restricted-${local.default_region1}-gke-svc"
- ip_cidr_range = "100.73.64.0/18"
- }
- ]
- }
-}
-
-module "base_env" {
- source = "../../modules/base_env"
-
- env = local.env
- environment_code = local.environment_code
- access_context_manager_policy_id = var.access_context_manager_policy_id
- perimeter_additional_members = var.perimeter_additional_members
- perimeter_additional_members_dry_run = var.perimeter_additional_members_dry_run
- default_region1 = local.default_region1
- default_region2 = local.default_region2
- domain = var.domain
- ingress_policies = var.ingress_policies
- ingress_policies_dry_run = var.ingress_policies_dry_run
- egress_policies = var.egress_policies
- egress_policies_dry_run = var.egress_policies_dry_run
- enable_partner_interconnect = false
- base_private_service_cidr = local.base_private_service_cidr
- base_subnet_primary_ranges = local.base_subnet_primary_ranges
- base_subnet_proxy_ranges = local.base_subnet_proxy_ranges
- base_subnet_secondary_ranges = local.base_subnet_secondary_ranges
- base_private_service_connect_ip = "10.17.0.2"
- restricted_private_service_cidr = local.restricted_private_service_cidr
- restricted_subnet_primary_ranges = local.restricted_subnet_primary_ranges
- restricted_subnet_proxy_ranges = local.restricted_subnet_proxy_ranges
- restricted_subnet_secondary_ranges = local.restricted_subnet_secondary_ranges
- restricted_private_service_connect_ip = "10.17.0.6"
- remote_state_bucket = var.remote_state_bucket
- tfc_org_name = var.tfc_org_name
-}
diff --git a/3-networks-dual-svpc/envs/development/outputs.tf b/3-networks-dual-svpc/envs/development/outputs.tf
deleted file mode 100644
index e71d3027e..000000000
--- a/3-networks-dual-svpc/envs/development/outputs.tf
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-output "access_context_manager_policy_id" {
- description = "Access Context Manager Policy ID."
- value = var.access_context_manager_policy_id
-}
-
-/*********************
- Restricted Outputs
-*********************/
-
-output "restricted_host_project_id" {
- value = module.base_env.restricted_host_project_id
- description = "The restricted host project ID"
-}
-
-output "restricted_network_name" {
- value = module.base_env.restricted_network_name
- description = "The name of the VPC being created"
-}
-
-output "restricted_network_self_link" {
- value = module.base_env.restricted_network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "restricted_subnets_names" {
- value = module.base_env.restricted_subnets_names
- description = "The names of the subnets being created"
-}
-
-output "restricted_subnets_ips" {
- value = module.base_env.restricted_subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "restricted_subnets_self_links" {
- value = module.base_env.restricted_subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "restricted_subnets_secondary_ranges" {
- value = module.base_env.restricted_subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
-
-output "access_level_name" {
- value = module.base_env.access_level_name
- description = "Access context manager access level name"
-}
-
-output "access_level_name_dry_run" {
- value = module.base_env.access_level_name_dry_run
- description = "Access context manager access level name for the dry-run perimeter"
-}
-
-output "enforce_vpcsc" {
- value = module.base_env.enforce_vpcsc
- description = "Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases."
-}
-
-output "restricted_service_perimeter_name" {
- value = module.base_env.restricted_service_perimeter_name
- description = "Access context manager service perimeter name"
-}
-
-
-/******************************************
- Private Outputs
-*****************************************/
-
-output "base_host_project_id" {
- value = module.base_env.base_host_project_id
- description = "The base host project ID"
-}
-
-output "base_network_name" {
- value = module.base_env.base_network_name
- description = "The name of the VPC being created"
-}
-
-output "base_network_self_link" {
- value = module.base_env.base_network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "base_subnets_names" {
- value = module.base_env.base_subnets_names
- description = "The names of the subnets being created"
-}
-
-output "base_subnets_ips" {
- value = module.base_env.base_subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "base_subnets_self_links" {
- value = module.base_env.base_subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "base_subnets_secondary_ranges" {
- value = module.base_env.base_subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
diff --git a/3-networks-dual-svpc/envs/nonproduction/main.tf b/3-networks-dual-svpc/envs/nonproduction/main.tf
deleted file mode 100644
index 6505a4478..000000000
--- a/3-networks-dual-svpc/envs/nonproduction/main.tf
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-locals {
- env = "nonproduction"
- environment_code = substr(local.env, 0, 1)
- /*
- * Base network ranges
- */
- base_private_service_cidr = "10.16.16.0/21"
- base_subnet_primary_ranges = {
- (local.default_region1) = "10.0.128.0/18"
- (local.default_region2) = "10.1.128.0/18"
- }
- base_subnet_proxy_ranges = {
- (local.default_region1) = "10.18.4.0/23"
- (local.default_region2) = "10.19.4.0/23"
- }
- base_subnet_secondary_ranges = {
- (local.default_region1) = [
- {
- range_name = "rn-${local.environment_code}-shared-base-${local.default_region1}-gke-pod"
- ip_cidr_range = "100.64.128.0/18"
- },
- {
- range_name = "rn-${local.environment_code}-shared-base-${local.default_region1}-gke-svc"
- ip_cidr_range = "100.65.128.0/18"
- }
- ]
- }
- /*
- * Restricted network ranges
- */
- restricted_private_service_cidr = "10.16.48.0/21"
- restricted_subnet_primary_ranges = {
- (local.default_region1) = "10.8.128.0/18"
- (local.default_region2) = "10.9.128.0/18"
- }
- restricted_subnet_proxy_ranges = {
- (local.default_region1) = "10.26.4.0/23"
- (local.default_region2) = "10.27.4.0/23"
- }
- restricted_subnet_secondary_ranges = {
- (local.default_region1) = [
- {
- range_name = "rn-${local.environment_code}-shared-restricted-${local.default_region1}-gke-pod"
- ip_cidr_range = "100.72.128.0/18"
- },
- {
- range_name = "rn-${local.environment_code}-shared-restricted-${local.default_region1}-gke-svc"
- ip_cidr_range = "100.73.128.0/18"
- }
- ]
- }
-}
-
-module "base_env" {
- source = "../../modules/base_env"
-
- env = local.env
- environment_code = local.environment_code
- access_context_manager_policy_id = var.access_context_manager_policy_id
- perimeter_additional_members = var.perimeter_additional_members
- perimeter_additional_members_dry_run = var.perimeter_additional_members_dry_run
- default_region1 = local.default_region1
- default_region2 = local.default_region2
- domain = var.domain
- ingress_policies = var.ingress_policies
- ingress_policies_dry_run = var.ingress_policies_dry_run
- egress_policies = var.egress_policies
- egress_policies_dry_run = var.egress_policies_dry_run
- enable_partner_interconnect = false
- base_private_service_cidr = local.base_private_service_cidr
- base_subnet_primary_ranges = local.base_subnet_primary_ranges
- base_subnet_proxy_ranges = local.base_subnet_proxy_ranges
- base_subnet_secondary_ranges = local.base_subnet_secondary_ranges
- base_private_service_connect_ip = "10.17.0.3"
- restricted_private_service_cidr = local.restricted_private_service_cidr
- restricted_subnet_proxy_ranges = local.restricted_subnet_proxy_ranges
- restricted_subnet_primary_ranges = local.restricted_subnet_primary_ranges
- restricted_subnet_secondary_ranges = local.restricted_subnet_secondary_ranges
- restricted_private_service_connect_ip = "10.17.0.7"
- remote_state_bucket = var.remote_state_bucket
- tfc_org_name = var.tfc_org_name
-}
diff --git a/3-networks-dual-svpc/envs/nonproduction/outputs.tf b/3-networks-dual-svpc/envs/nonproduction/outputs.tf
deleted file mode 100644
index ae890e4d2..000000000
--- a/3-networks-dual-svpc/envs/nonproduction/outputs.tf
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-output "access_context_manager_policy_id" {
- description = "Access Context Manager Policy ID."
- value = var.access_context_manager_policy_id
-}
-
-/*********************
- Restricted Outputs
-*********************/
-
-output "restricted_host_project_id" {
- value = module.base_env.restricted_host_project_id
- description = "The restricted host project ID"
-}
-
-output "restricted_network_name" {
- value = module.base_env.restricted_network_name
- description = "The name of the VPC being created"
-}
-
-output "restricted_network_self_link" {
- value = module.base_env.restricted_network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "restricted_subnets_names" {
- value = module.base_env.restricted_subnets_names
- description = "The names of the subnets being created"
-}
-
-output "restricted_subnets_ips" {
- value = module.base_env.restricted_subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "restricted_subnets_self_links" {
- value = module.base_env.restricted_subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "restricted_subnets_secondary_ranges" {
- value = module.base_env.restricted_subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
-
-output "access_level_name" {
- value = module.base_env.access_level_name
- description = "Access context manager access level name"
-}
-
-output "access_level_name_dry_run" {
- value = module.base_env.access_level_name_dry_run
- description = "Access context manager access level name for the dry-run perimeter"
-}
-
-output "enforce_vpcsc" {
- value = module.base_env.enforce_vpcsc
- description = "Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases."
-}
-
-output "restricted_service_perimeter_name" {
- value = module.base_env.restricted_service_perimeter_name
- description = "Access context manager service perimeter name"
-}
-
-/******************************************
- Private Outputs
-*****************************************/
-
-output "base_host_project_id" {
- value = module.base_env.base_host_project_id
- description = "The base host project ID"
-}
-
-output "base_network_name" {
- value = module.base_env.base_network_name
- description = "The name of the VPC being created"
-}
-
-output "base_network_self_link" {
- value = module.base_env.base_network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "base_subnets_names" {
- value = module.base_env.base_subnets_names
- description = "The names of the subnets being created"
-}
-
-output "base_subnets_ips" {
- value = module.base_env.base_subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "base_subnets_self_links" {
- value = module.base_env.base_subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "base_subnets_secondary_ranges" {
- value = module.base_env.base_subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
diff --git a/3-networks-dual-svpc/envs/production/main.tf b/3-networks-dual-svpc/envs/production/main.tf
deleted file mode 100644
index e68a0454e..000000000
--- a/3-networks-dual-svpc/envs/production/main.tf
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-locals {
- env = "production"
- environment_code = substr(local.env, 0, 1)
- /*
- * Base network ranges
- */
- base_private_service_cidr = "10.16.24.0/21"
- base_subnet_primary_ranges = {
- (local.default_region1) = "10.0.192.0/18"
- (local.default_region2) = "10.1.192.0/18"
- }
- base_subnet_proxy_ranges = {
- (local.default_region1) = "10.18.6.0/23"
- (local.default_region2) = "10.19.6.0/23"
- }
- base_subnet_secondary_ranges = {
- (local.default_region1) = [
- {
- range_name = "rn-${local.environment_code}-shared-base-${local.default_region1}-gke-pod"
- ip_cidr_range = "100.64.192.0/18"
- },
- {
- range_name = "rn-${local.environment_code}-shared-base-${local.default_region1}-gke-svc"
- ip_cidr_range = "100.65.192.0/18"
- }
- ]
- }
- /*
- * Restricted network ranges
- */
- restricted_private_service_cidr = "10.16.56.0/21"
- restricted_subnet_primary_ranges = {
- (local.default_region1) = "10.8.192.0/18"
- (local.default_region2) = "10.9.192.0/18"
- }
- restricted_subnet_proxy_ranges = {
- (local.default_region1) = "10.26.6.0/23"
- (local.default_region2) = "10.27.6.0/23"
- }
- restricted_subnet_secondary_ranges = {
- (local.default_region1) = [
- {
- range_name = "rn-${local.environment_code}-shared-restricted-${local.default_region1}-gke-pod"
- ip_cidr_range = "100.72.192.0/18"
- },
- {
- range_name = "rn-${local.environment_code}-shared-restricted-${local.default_region1}-gke-svc"
- ip_cidr_range = "100.73.192.0/18"
- }
- ]
- }
-}
-
-module "base_env" {
- source = "../../modules/base_env"
-
- env = local.env
- environment_code = local.environment_code
- access_context_manager_policy_id = var.access_context_manager_policy_id
- perimeter_additional_members = var.perimeter_additional_members
- perimeter_additional_members_dry_run = var.perimeter_additional_members_dry_run
- default_region1 = local.default_region1
- default_region2 = local.default_region2
- domain = var.domain
- ingress_policies = var.ingress_policies
- ingress_policies_dry_run = var.ingress_policies_dry_run
- egress_policies = var.egress_policies
- egress_policies_dry_run = var.egress_policies_dry_run
- enable_partner_interconnect = false
- base_private_service_cidr = local.base_private_service_cidr
- base_subnet_primary_ranges = local.base_subnet_primary_ranges
- base_subnet_proxy_ranges = local.base_subnet_proxy_ranges
- base_subnet_secondary_ranges = local.base_subnet_secondary_ranges
- base_private_service_connect_ip = "10.17.0.4"
- restricted_private_service_cidr = local.restricted_private_service_cidr
- restricted_subnet_proxy_ranges = local.restricted_subnet_proxy_ranges
- restricted_subnet_primary_ranges = local.restricted_subnet_primary_ranges
- restricted_subnet_secondary_ranges = local.restricted_subnet_secondary_ranges
- restricted_private_service_connect_ip = "10.17.0.8"
- remote_state_bucket = var.remote_state_bucket
- tfc_org_name = var.tfc_org_name
- target_name_server_addresses = var.target_name_server_addresses
-}
diff --git a/3-networks-dual-svpc/envs/production/outputs.tf b/3-networks-dual-svpc/envs/production/outputs.tf
deleted file mode 100644
index ae890e4d2..000000000
--- a/3-networks-dual-svpc/envs/production/outputs.tf
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-output "access_context_manager_policy_id" {
- description = "Access Context Manager Policy ID."
- value = var.access_context_manager_policy_id
-}
-
-/*********************
- Restricted Outputs
-*********************/
-
-output "restricted_host_project_id" {
- value = module.base_env.restricted_host_project_id
- description = "The restricted host project ID"
-}
-
-output "restricted_network_name" {
- value = module.base_env.restricted_network_name
- description = "The name of the VPC being created"
-}
-
-output "restricted_network_self_link" {
- value = module.base_env.restricted_network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "restricted_subnets_names" {
- value = module.base_env.restricted_subnets_names
- description = "The names of the subnets being created"
-}
-
-output "restricted_subnets_ips" {
- value = module.base_env.restricted_subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "restricted_subnets_self_links" {
- value = module.base_env.restricted_subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "restricted_subnets_secondary_ranges" {
- value = module.base_env.restricted_subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
-
-output "access_level_name" {
- value = module.base_env.access_level_name
- description = "Access context manager access level name"
-}
-
-output "access_level_name_dry_run" {
- value = module.base_env.access_level_name_dry_run
- description = "Access context manager access level name for the dry-run perimeter"
-}
-
-output "enforce_vpcsc" {
- value = module.base_env.enforce_vpcsc
- description = "Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases."
-}
-
-output "restricted_service_perimeter_name" {
- value = module.base_env.restricted_service_perimeter_name
- description = "Access context manager service perimeter name"
-}
-
-/******************************************
- Private Outputs
-*****************************************/
-
-output "base_host_project_id" {
- value = module.base_env.base_host_project_id
- description = "The base host project ID"
-}
-
-output "base_network_name" {
- value = module.base_env.base_network_name
- description = "The name of the VPC being created"
-}
-
-output "base_network_self_link" {
- value = module.base_env.base_network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "base_subnets_names" {
- value = module.base_env.base_subnets_names
- description = "The names of the subnets being created"
-}
-
-output "base_subnets_ips" {
- value = module.base_env.base_subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "base_subnets_self_links" {
- value = module.base_env.base_subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "base_subnets_secondary_ranges" {
- value = module.base_env.base_subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
diff --git a/3-networks-dual-svpc/modules/base_env/outputs.tf b/3-networks-dual-svpc/modules/base_env/outputs.tf
deleted file mode 100644
index 2b8044a12..000000000
--- a/3-networks-dual-svpc/modules/base_env/outputs.tf
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-output "target_name_server_addresses" {
- value = var.target_name_server_addresses
- description = "List of IPv4 addresses of the target name servers for the forwarding zone configuration. These IP addresses should point to the name server responsible for replying to DNS queries."
-}
-
-
-/*********************
- Restricted Outputs
-*********************/
-
-output "restricted_dns_project_id" {
- value = local.restricted_dns_project_id
- description = "The restricted DNS project ID"
-}
-
-output "restricted_host_project_id" {
- value = local.restricted_project_id
- description = "The restricted host project ID"
-}
-
-output "restricted_network_name" {
- value = module.restricted_shared_vpc.network_name
- description = "The name of the VPC being created"
-}
-
-output "restricted_network_self_link" {
- value = module.restricted_shared_vpc.network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "restricted_subnets_names" {
- value = module.restricted_shared_vpc.subnets_names
- description = "The names of the subnets being created"
-}
-
-output "restricted_subnets_ips" {
- value = module.restricted_shared_vpc.subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "restricted_subnets_self_links" {
- value = module.restricted_shared_vpc.subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "restricted_subnets_secondary_ranges" {
- value = module.restricted_shared_vpc.subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
-
-output "access_level_name" {
- value = module.restricted_shared_vpc.access_level_name
- description = "Access context manager access level name for the enforced perimeter"
-}
-
-output "access_level_name_dry_run" {
- value = module.restricted_shared_vpc.access_level_name_dry_run
- description = "Access context manager access level name for the dry-run perimeter"
-}
-
-output "enforce_vpcsc" {
- value = module.restricted_shared_vpc.enforce_vpcsc
- description = "Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases."
-}
-
-output "restricted_service_perimeter_name" {
- value = module.restricted_shared_vpc.service_perimeter_name
- description = "Access context manager service perimeter name for the enforced perimeter"
-}
-
-
-
-/******************************************
- Private Outputs
-*****************************************/
-
-output "base_dns_project_id" {
- value = local.base_dns_project_id
- description = "The base DNS project ID"
-}
-
-output "base_host_project_id" {
- value = local.base_project_id
- description = "The base host project ID"
-}
-
-output "base_network_name" {
- value = module.base_shared_vpc.network_name
- description = "The name of the VPC being created"
-}
-
-output "base_network_self_link" {
- value = module.base_shared_vpc.network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "base_subnets_names" {
- value = module.base_shared_vpc.subnets_names
- description = "The names of the subnets being created"
-}
-
-output "base_subnets_ips" {
- value = module.base_shared_vpc.subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "base_subnets_self_links" {
- value = module.base_shared_vpc.subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "base_subnets_secondary_ranges" {
- value = module.base_shared_vpc.subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
-
diff --git a/3-networks-dual-svpc/modules/base_env/partner_interconnect.tf.example b/3-networks-dual-svpc/modules/base_env/partner_interconnect.tf.example
deleted file mode 100644
index c5e616db7..000000000
--- a/3-networks-dual-svpc/modules/base_env/partner_interconnect.tf.example
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-module "shared_restricted_interconnect" {
- source = "../partner_interconnect"
-
- attachment_project_id = local.restricted_project_id
- vpc_name = "${var.environment_code}-shared-restricted"
- preactivate = true
-
- region1 = var.default_region1
- region1_router1_name = module.restricted_shared_vpc.region1_router1.router.name
- region1_interconnect1_location = "las-zone1-770"
- region1_interconnect1_onprem_dc = "onprem-dc1"
- region1_router2_name = module.restricted_shared_vpc.region1_router2.router.name
- region1_interconnect2_location = "las-zone1-770"
- region1_interconnect2_onprem_dc = "onprem-dc2"
-
- region2 = var.default_region2
- region2_router1_name = module.restricted_shared_vpc.region2_router1.router.name
- region2_interconnect1_location = "lax-zone2-19"
- region2_interconnect1_onprem_dc = "onprem-dc3"
- region2_router2_name = module.restricted_shared_vpc.region2_router2.router.name
- region2_interconnect2_location = "lax-zone1-403"
- region2_interconnect2_onprem_dc = "onprem-dc4"
-
- cloud_router_labels = {
- vlan_1 = "cr5",
- vlan_2 = "cr6",
- vlan_3 = "cr7",
- vlan_4 = "cr8"
- }
-
- depends_on = [
- module.restricted_shared_vpc
- ]
-}
-
-module "shared_base_interconnect" {
- source = "../partner_interconnect"
-
- attachment_project_id = local.base_project_id
- vpc_name = "${var.environment_code}-shared-base"
- preactivate = true
-
- region1 = var.default_region1
- region1_router1_name = module.base_shared_vpc.region1_router1.router.name
- region1_interconnect1_location = "las-zone1-770"
- region1_interconnect1_onprem_dc = "onprem-dc1"
- region1_router2_name = module.base_shared_vpc.region1_router2.router.name
- region1_interconnect2_location = "las-zone1-770"
- region1_interconnect2_onprem_dc = "onprem-dc2"
-
- region2 = var.default_region2
- region2_router1_name = module.base_shared_vpc.region2_router1.router.name
- region2_interconnect1_location = "lax-zone2-19"
- region2_interconnect1_onprem_dc = "onprem-dc3"
- region2_router2_name = module.base_shared_vpc.region2_router2.router.name
- region2_interconnect2_location = "lax-zone1-403"
- region2_interconnect2_onprem_dc = "onprem-dc4"
-
-
- cloud_router_labels = {
- vlan_1 = "cr1",
- vlan_2 = "cr2",
- vlan_3 = "cr3",
- vlan_4 = "cr4"
- }
-
- depends_on = [
- module.base_shared_vpc
- ]
-}
diff --git a/3-networks-dual-svpc/modules/base_env/vpn.tf.example b/3-networks-dual-svpc/modules/base_env/vpn.tf.example
deleted file mode 100644
index 355134e37..000000000
--- a/3-networks-dual-svpc/modules/base_env/vpn.tf.example
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-locals {
- env_secret_project_id = data.terraform_remote_state.environments_env.outputs.env_secrets_project_id
-}
-
-data "terraform_remote_state" "environments_env" {
- backend = "gcs"
-
- config = {
- bucket = var.remote_state_bucket
- prefix = "terraform/environments/${var.env}"
- }
-}
-
-module "shared_base_vpn" {
- source = "../vpn-ha"
-
- project_id = local.base_project_id
- env_secret_project_id = local.env_secret_project_id
- default_region1 = var.default_region1
- default_region2 = var.default_region2
- vpc_name = "${var.environment_code}-shared-base"
- region1_router1_name = module.base_shared_vpc.region1_router1.router.name
- region1_router2_name = module.base_shared_vpc.region1_router2.router.name
- region2_router1_name = module.base_shared_vpc.region2_router1.router.name
- region2_router2_name = module.base_shared_vpc.region2_router2.router.name
- vpn_psk_secret_name = "list(object({
subnet_name = string
subnet_ip = string
subnet_region = string
subnet_private_access = optional(string, "false")
subnet_private_ipv6_access = optional(string)
subnet_flow_logs = optional(string, "false")
subnet_flow_logs_interval = optional(string, "INTERVAL_5_SEC")
subnet_flow_logs_sampling = optional(string, "0.5")
subnet_flow_logs_metadata = optional(string, "INCLUDE_ALL_METADATA")
subnet_flow_logs_filter = optional(string, "true")
subnet_flow_logs_metadata_fields = optional(list(string), [])
description = optional(string)
purpose = optional(string)
role = optional(string)
stack_type = optional(string)
ipv6_access_type = optional(string)
})) | `[]` | no |
-| target\_name\_server\_addresses | List of IPv4 address of target name servers for the forwarding zone configuration. See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones for details on target name servers in the context of Cloud DNS forwarding zones. | `list(map(any))` | n/a | yes |
-| windows\_activation\_enabled | Enable Windows license activation for Windows workloads. | `bool` | `false` | no |
-
-## Outputs
-
-| Name | Description |
-|------|-------------|
-| network\_name | The name of the VPC being created |
-| network\_self\_link | The URI of the VPC being created |
-| region1\_router1 | Router 1 for Region 1 |
-| region1\_router2 | Router 2 for Region 1 |
-| region2\_router1 | Router 1 for Region 2 |
-| region2\_router2 | Router 2 for Region 2 |
-| subnets\_flow\_logs | Whether the subnets have VPC flow logs enabled |
-| subnets\_ips | The IPs and CIDRs of the subnets being created |
-| subnets\_names | The names of the subnets being created |
-| subnets\_private\_access | Whether the subnets have access to Google API's without a public IP |
-| subnets\_regions | The region where the subnets will be created |
-| subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
-| subnets\_self\_links | The self-links of subnets being created |
-
-
diff --git a/3-networks-dual-svpc/modules/base_shared_vpc/firewall.tf b/3-networks-dual-svpc/modules/base_shared_vpc/firewall.tf
deleted file mode 100644
index 57764a609..000000000
--- a/3-networks-dual-svpc/modules/base_shared_vpc/firewall.tf
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/******************************************
- Mandatory and optional firewall rules
- *****************************************/
-module "firewall_rules" {
- source = "terraform-google-modules/network/google//modules/network-firewall-policy"
- version = "~> 10.0"
-
- project_id = var.project_id
- policy_name = "fp-${var.environment_code}-dual-svpc-base-firewalls"
- description = "Firewall rules for base dual shared vpc: ${module.main.network_name}."
- target_vpcs = ["projects/${var.project_id}/global/networks/${module.main.network_name}"]
-
- rules = concat(
- [
- {
- priority = "65530"
- direction = "EGRESS"
- action = "deny"
- rule_name = "fw-${var.environment_code}-shared-base-65530-e-d-all-all-all"
- description = "Lower priority rule to deny all egress traffic."
- enable_logging = var.firewall_enable_logging
- match = {
- dest_ip_ranges = ["0.0.0.0/0"]
- layer4_configs = [
- {
- ip_protocol = "all"
- },
- ]
- }
- },
- {
- priority = "1000"
- direction = "EGRESS"
- action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-1000-e-a-allow-google-apis-all-tcp-443"
- description = "Lower priority rule to allow private google apis on TCP port 443."
- enable_logging = var.firewall_enable_logging
- match = {
- dest_ip_ranges = [local.private_googleapis_cidr]
- layer4_configs = [
- {
- ip_protocol = "tcp"
- ports = ["443"]
- },
- ]
- }
- }
- ],
- !var.enable_all_vpc_internal_traffic ? [] : [
- {
- priority = "10000"
- direction = "EGRESS"
- action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-10000-e-a-all-all-all"
- description = "Allow all egress to the provided IP range."
- enable_logging = var.firewall_enable_logging
- match = {
- dest_ip_ranges = module.main.subnets_ips
- layer4_configs = [
- {
- ip_protocol = "all"
- },
- ]
- }
- }
- ],
- !var.enable_all_vpc_internal_traffic ? [] : [
- {
- priority = "10001"
- direction = "INGRESS"
- action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-10001-i-a-all"
- description = "Allow all ingress to the provided IP range."
- enable_logging = var.firewall_enable_logging
- match = {
- src_ip_ranges = module.main.subnets_ips
- layer4_configs = [
- {
- ip_protocol = "all"
- },
- ]
- }
- }
- ]
- )
-}
diff --git a/3-networks-dual-svpc/modules/base_shared_vpc/main.tf b/3-networks-dual-svpc/modules/base_shared_vpc/main.tf
deleted file mode 100644
index d5ad2522c..000000000
--- a/3-networks-dual-svpc/modules/base_shared_vpc/main.tf
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-locals {
- vpc_name = "${var.environment_code}-shared-base"
- network_name = "vpc-${local.vpc_name}"
- private_googleapis_cidr = module.private_service_connect.private_service_connect_ip
- google_forward_source_range = "35.199.192.0/19"
- advertised_ip = var.environment_code == "p" ? [{ range = local.google_forward_source_range }, { range = local.private_googleapis_cidr }] : [{ range = local.private_googleapis_cidr }]
-
-}
-
-/******************************************
- Shared VPC configuration
- *****************************************/
-
-module "main" {
- source = "terraform-google-modules/network/google"
- version = "~> 10.0"
-
- project_id = var.project_id
- network_name = local.network_name
- shared_vpc_host = "true"
- delete_default_internet_gateway_routes = "true"
-
- subnets = var.subnets
- secondary_ranges = var.secondary_ranges
-
- routes = concat(
- var.nat_enabled ?
- [
- {
- name = "rt-${local.vpc_name}-1000-egress-internet-default"
- description = "Tag based route through IGW to access internet"
- destination_range = "0.0.0.0/0"
- tags = "egress-internet"
- next_hop_internet = "true"
- priority = "1000"
- }
- ]
- : [],
- var.windows_activation_enabled ?
- [{
- name = "rt-${local.vpc_name}-1000-all-default-windows-kms"
- description = "Route through IGW to allow Windows KMS activation for GCP."
- destination_range = "35.190.247.13/32"
- next_hop_internet = "true"
- priority = "1000"
- }
- ]
- : []
- )
-}
-
-
-/***************************************************************
- Configure Service Networking for Cloud SQL & future services.
- **************************************************************/
-
-resource "google_compute_global_address" "private_service_access_address" {
- count = var.private_service_cidr != null ? 1 : 0
- name = "ga-${local.vpc_name}-vpc-peering-internal"
- project = var.project_id
- purpose = "VPC_PEERING"
- address_type = "INTERNAL"
- address = element(split("/", var.private_service_cidr), 0)
- prefix_length = element(split("/", var.private_service_cidr), 1)
- network = module.main.network_self_link
-
-}
-
-resource "google_service_networking_connection" "private_vpc_connection" {
- count = var.private_service_cidr != null ? 1 : 0
- network = module.main.network_self_link
- service = "servicenetworking.googleapis.com"
- reserved_peering_ranges = [google_compute_global_address.private_service_access_address[0].name]
-}
-
-/************************************
- Router to advertise shared VPC
- subnetworks and Google Private API
-************************************/
-
-module "region1_router1" {
- source = "terraform-google-modules/cloud-router/google"
- version = "~> 6.0"
-
- name = "cr-${local.vpc_name}-${var.default_region1}-cr1"
- project = var.project_id
- network = module.main.network_name
- region = var.default_region1
- bgp = {
- asn = var.bgp_asn_subnet
- advertised_groups = ["ALL_SUBNETS"]
- advertised_ip_ranges = local.advertised_ip
- }
-}
-
-module "region1_router2" {
- source = "terraform-google-modules/cloud-router/google"
- version = "~> 6.0"
-
- name = "cr-${local.vpc_name}-${var.default_region1}-cr2"
- project = var.project_id
- network = module.main.network_name
- region = var.default_region1
- bgp = {
- asn = var.bgp_asn_subnet
- advertised_groups = ["ALL_SUBNETS"]
- advertised_ip_ranges = local.advertised_ip
- }
-}
-
-module "region2_router1" {
- source = "terraform-google-modules/cloud-router/google"
- version = "~> 6.0"
-
- name = "cr-${local.vpc_name}-${var.default_region2}-cr3"
- project = var.project_id
- network = module.main.network_name
- region = var.default_region2
- bgp = {
- asn = var.bgp_asn_subnet
- advertised_groups = ["ALL_SUBNETS"]
- advertised_ip_ranges = local.advertised_ip
- }
-}
-
-module "region2_router2" {
- source = "terraform-google-modules/cloud-router/google"
- version = "~> 6.0"
-
- name = "cr-${local.vpc_name}-${var.default_region2}-cr4"
- project = var.project_id
- network = module.main.network_name
- region = var.default_region2
- bgp = {
- asn = var.bgp_asn_subnet
- advertised_groups = ["ALL_SUBNETS"]
- advertised_ip_ranges = local.advertised_ip
- }
-}
-
diff --git a/3-networks-dual-svpc/modules/base_shared_vpc/nat.tf b/3-networks-dual-svpc/modules/base_shared_vpc/nat.tf
deleted file mode 100644
index 600a06f8c..000000000
--- a/3-networks-dual-svpc/modules/base_shared_vpc/nat.tf
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/******************************************
- NAT Cloud Router & NAT config
- *****************************************/
-
-resource "google_compute_router" "nat_router_region1" {
- count = var.nat_enabled ? 1 : 0
- name = "cr-${local.vpc_name}-${var.default_region1}-nat-router"
- project = var.project_id
- region = var.default_region1
- network = module.main.network_self_link
-
- bgp {
- asn = var.nat_bgp_asn
- }
-}
-
-resource "google_compute_address" "nat_external_addresses_region1" {
- count = var.nat_enabled ? var.nat_num_addresses_region1 : 0
- project = var.project_id
- name = "ca-${local.vpc_name}-${var.default_region1}-${count.index}"
- region = var.default_region1
-}
-
-resource "google_compute_router_nat" "egress_nat_region1" {
- count = var.nat_enabled ? 1 : 0
- name = "rn-${local.vpc_name}-${var.default_region1}-egress"
- project = var.project_id
- router = google_compute_router.nat_router_region1[0].name
- region = var.default_region1
- nat_ip_allocate_option = "MANUAL_ONLY"
- nat_ips = google_compute_address.nat_external_addresses_region1.*.self_link
- source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
-
- log_config {
- filter = "TRANSLATIONS_ONLY"
- enable = true
- }
-}
-
-resource "google_compute_router" "nat_router_region2" {
- count = var.nat_enabled ? 1 : 0
- name = "cr-${local.vpc_name}-${var.default_region2}-nat-router"
- project = var.project_id
- region = var.default_region2
- network = module.main.network_self_link
-
- bgp {
- asn = var.nat_bgp_asn
- }
-}
-
-resource "google_compute_address" "nat_external_addresses_region2" {
- count = var.nat_enabled ? var.nat_num_addresses_region2 : 0
- project = var.project_id
- name = "ca-${local.vpc_name}-${var.default_region2}-${count.index}"
- region = var.default_region2
-}
-
-resource "google_compute_router_nat" "egress_nat2" {
- count = var.nat_enabled ? 1 : 0
- name = "rn-${local.vpc_name}-${var.default_region2}-egress"
- project = var.project_id
- router = google_compute_router.nat_router_region2[0].name
- region = var.default_region2
- nat_ip_allocate_option = "MANUAL_ONLY"
- nat_ips = google_compute_address.nat_external_addresses_region2.*.self_link
- source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
-
- log_config {
- filter = "TRANSLATIONS_ONLY"
- enable = true
- }
-}
diff --git a/3-networks-dual-svpc/modules/base_shared_vpc/outputs.tf b/3-networks-dual-svpc/modules/base_shared_vpc/outputs.tf
deleted file mode 100644
index f2e9e6eeb..000000000
--- a/3-networks-dual-svpc/modules/base_shared_vpc/outputs.tf
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-output "network_name" {
- value = module.main.network_name
- description = "The name of the VPC being created"
-}
-
-output "network_self_link" {
- value = module.main.network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "subnets_names" {
- value = module.main.subnets_names
- description = "The names of the subnets being created"
-}
-
-output "subnets_ips" {
- value = module.main.subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "subnets_self_links" {
- value = module.main.subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "subnets_regions" {
- value = module.main.subnets_regions
- description = "The region where the subnets will be created"
-}
-
-output "subnets_private_access" {
- value = module.main.subnets_private_access
- description = "Whether the subnets have access to Google API's without a public IP"
-}
-
-output "subnets_flow_logs" {
- value = module.main.subnets_flow_logs
- description = "Whether the subnets have VPC flow logs enabled"
-}
-
-output "subnets_secondary_ranges" {
- value = module.main.subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
-
-output "region1_router1" {
- value = module.region1_router1
- description = "Router 1 for Region 1"
-}
-
-output "region1_router2" {
- value = module.region1_router2
- description = "Router 2 for Region 1"
-}
-
-output "region2_router1" {
- value = module.region2_router1
- description = "Router 1 for Region 2"
-}
-
-output "region2_router2" {
- value = module.region2_router2
- description = "Router 2 for Region 2"
-}
-
diff --git a/3-networks-dual-svpc/modules/base_shared_vpc/private_service_connect.tf b/3-networks-dual-svpc/modules/base_shared_vpc/private_service_connect.tf
deleted file mode 100644
index 0052c3009..000000000
--- a/3-networks-dual-svpc/modules/base_shared_vpc/private_service_connect.tf
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-module "private_service_connect" {
- source = "terraform-google-modules/network/google//modules/private-service-connect"
- version = "~> 10.0"
-
- project_id = var.project_id
- dns_code = "dz-${var.environment_code}-shared-base"
- network_self_link = module.main.network_self_link
- private_service_connect_ip = var.private_service_connect_ip
- forwarding_rule_target = "all-apis"
- service_directory_region = var.default_region1
-}
diff --git a/3-networks-dual-svpc/modules/base_shared_vpc/variables.tf b/3-networks-dual-svpc/modules/base_shared_vpc/variables.tf
deleted file mode 100644
index d1cab59d4..000000000
--- a/3-networks-dual-svpc/modules/base_shared_vpc/variables.tf
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-variable "base_dns_project_id" {
- description = "Project ID for DNS Base Shared."
- type = string
- default = ""
-}
-
-variable "target_name_server_addresses" {
- description = "List of IPv4 address of target name servers for the forwarding zone configuration. See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones for details on target name servers in the context of Cloud DNS forwarding zones."
- type = list(map(any))
-}
-
-variable "base_network_name" {
- type = string
- description = "The name of the VPC being created"
- default = ""
-}
-
-variable "project_id" {
- type = string
- description = "Project ID for Private Shared VPC."
-}
-
-
-variable "environment_code" {
- type = string
- description = "A short form of the folder level resources (environment) within the Google Cloud organization."
-}
-
-variable "default_region1" {
- type = string
- description = "Default region 1 for subnets and Cloud Routers"
-}
-
-variable "default_region2" {
- type = string
- description = "Default region 2 for subnets and Cloud Routers"
-}
-
-variable "nat_enabled" {
- type = bool
- description = "Toggle creation of NAT cloud router."
- default = false
-}
-
-variable "nat_bgp_asn" {
- type = number
- description = "BGP ASN for first NAT cloud routes."
- default = 64514
-}
-
-variable "nat_num_addresses_region1" {
- type = number
- description = "Number of external IPs to reserve for first Cloud NAT."
- default = 2
-}
-
-variable "nat_num_addresses_region2" {
- type = number
- description = "Number of external IPs to reserve for second Cloud NAT."
- default = 2
-}
-
-variable "bgp_asn_subnet" {
- type = number
- description = "BGP ASN for Subnets cloud routers."
-}
-
-variable "subnets" {
- type = list(object({
- subnet_name = string
- subnet_ip = string
- subnet_region = string
- subnet_private_access = optional(string, "false")
- subnet_private_ipv6_access = optional(string)
- subnet_flow_logs = optional(string, "false")
- subnet_flow_logs_interval = optional(string, "INTERVAL_5_SEC")
- subnet_flow_logs_sampling = optional(string, "0.5")
- subnet_flow_logs_metadata = optional(string, "INCLUDE_ALL_METADATA")
- subnet_flow_logs_filter = optional(string, "true")
- subnet_flow_logs_metadata_fields = optional(list(string), [])
- description = optional(string)
- purpose = optional(string)
- role = optional(string)
- stack_type = optional(string)
- ipv6_access_type = optional(string)
- }))
- description = "The list of subnets being created"
- default = []
-}
-
-variable "secondary_ranges" {
- type = map(list(object({ range_name = string, ip_cidr_range = string })))
- description = "Secondary ranges that will be used in some of the subnets"
- default = {}
-}
-
-variable "dns_enable_inbound_forwarding" {
- type = bool
- description = "Toggle inbound query forwarding for VPC DNS."
- default = true
-}
-
-variable "dns_enable_logging" {
- type = bool
- description = "Toggle DNS logging for VPC DNS."
- default = true
-}
-
-variable "firewall_enable_logging" {
- type = bool
- description = "Toggle firewall logging for VPC Firewalls."
- default = true
-}
-
-variable "domain" {
- type = string
- description = "The DNS name of peering managed zone, for instance 'example.com.'"
-}
-
-variable "private_service_cidr" {
- type = string
- description = "CIDR range for private service networking. Used for Cloud SQL and other managed services."
- default = null
-}
-
-variable "private_service_connect_ip" {
- type = string
- description = "Internal IP to be used as the private service connect endpoint"
-}
-
-variable "windows_activation_enabled" {
- type = bool
- description = "Enable Windows license activation for Windows workloads."
- default = false
-}
-
-variable "enable_all_vpc_internal_traffic" {
- type = bool
- description = "Enable firewall policy rule to allow internal traffic (ingress and egress)."
- default = false
-}
-
diff --git a/3-networks-dual-svpc/modules/base_shared_vpc/versions.tf b/3-networks-dual-svpc/modules/base_shared_vpc/versions.tf
deleted file mode 100644
index 4624e5927..000000000
--- a/3-networks-dual-svpc/modules/base_shared_vpc/versions.tf
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-terraform {
- required_version = ">= 0.13"
- required_providers {
- google = {
- source = "hashicorp/google"
- version = ">= 3.50"
- }
- google-beta = {
- source = "hashicorp/google-beta"
- version = ">= 3.50"
- }
- }
-
- provider_meta "google" {
- module_name = "blueprints/terraform/terraform-example-foundation:base_shared_vpc/v4.1.0"
- }
-
- provider_meta "google-beta" {
- module_name = "blueprints/terraform/terraform-example-foundation:base_shared_vpc/v4.1.0"
- }
-}
diff --git a/3-networks-dual-svpc/modules/restricted_shared_vpc/dns.tf b/3-networks-dual-svpc/modules/restricted_shared_vpc/dns.tf
deleted file mode 100644
index 85b190d82..000000000
--- a/3-networks-dual-svpc/modules/restricted_shared_vpc/dns.tf
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * Copyright 2021 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/******************************************
- Default DNS Policy
- *****************************************/
-
-resource "google_dns_policy" "default_policy" {
- project = var.project_id
- name = "dp-${var.environment_code}-shared-restricted-default-policy"
- enable_inbound_forwarding = var.dns_enable_inbound_forwarding
- enable_logging = var.dns_enable_logging
- networks {
- network_url = module.main.network_self_link
- }
-}
-
-/******************************************
- Creates DNS Peering to DNS HUB
-*****************************************/
-data "google_compute_network" "vpc_dns_hub" {
-
- count = var.environment_code != "p" ? 1 : 0
-
- name = "vpc-p-shared-restricted"
- project = var.restricted_dns_project_id
-}
-
-module "peering_zone" {
- source = "terraform-google-modules/cloud-dns/google"
- version = "~> 5.0"
-
- count = var.environment_code != "p" ? 1 : 0
-
- project_id = var.project_id
- type = "peering"
- name = "dz-${var.environment_code}-shared-restricted-to-dns-hub"
- domain = var.domain
- description = "Private DNS peering zone."
-
- private_visibility_config_networks = [
- module.main.network_self_link
- ]
- target_network = data.google_compute_network.vpc_dns_hub[0].self_link
-}
-
-/******************************************
- DNS Forwarding
-*****************************************/
-module "dns_forwarding_zone" {
- source = "terraform-google-modules/cloud-dns/google"
- version = "~> 5.0"
-
- count = var.environment_code == "p" ? 1 : 0
-
- project_id = var.project_id
- type = "forwarding"
- name = "fz-dns-hub"
- domain = var.domain
-
- private_visibility_config_networks = [
- module.main.network_self_link
- ]
- target_name_server_addresses = var.target_name_server_addresses
-}
-
diff --git a/3-networks-hub-and-spoke/README.md b/3-networks-hub-and-spoke/README.md
index 2607a7e7c..362ceb08c 100644
--- a/3-networks-hub-and-spoke/README.md
+++ b/3-networks-hub-and-spoke/README.md
@@ -25,16 +25,16 @@ organizational policy.
Google Cloud organization that you've created.
object({
enable_logging = optional(string, "true")
aggregation_interval = optional(string, "INTERVAL_5_SEC")
flow_sampling = optional(string, "0.5")
metadata = optional(string, "INCLUDE_ALL_METADATA")
metadata_fields = optional(list(string), [])
filter_expr = optional(string, "true")
}) | `{}` | no |
| bgp\_asn\_dns | BGP Autonomous System Number (ASN). | `number` | `64667` | no |
| custom\_restricted\_services | List of custom services to be protected by the VPC-SC perimeter. If empty, all supported services (https://cloud.google.com/vpc-service-controls/docs/supported-products) will be protected. | `list(string)` | `[]` | no |
| dns\_enable\_logging | Toggle DNS logging for VPC DNS. | `bool` | `true` | no |
@@ -32,31 +23,28 @@ The purpose of this step is to set up the global [DNS Hub](https://cloud.google.
| enable\_hub\_and\_spoke\_transitivity | Enable transitivity via gateway VMs on Hub-and-Spoke architecture. | `bool` | `false` | no |
| enable\_partner\_interconnect | Enable Partner Interconnect in the environment. | `bool` | `false` | no |
| firewall\_policies\_enable\_logging | Toggle hierarchical firewall logging. | `bool` | `true` | no |
+| hub\_dns\_enable\_inbound\_forwarding | Toggle inbound query forwarding for Shared Hub VPC DNS. | `bool` | `true` | no |
+| hub\_dns\_enable\_logging | Toggle DNS logging for Shared Hub VPC DNS. | `bool` | `true` | no |
+| hub\_firewall\_enable\_logging | Toggle firewall logging for VPC Firewalls in Shared Hub VPC. | `bool` | `true` | no |
+| hub\_nat\_bgp\_asn | BGP ASN for first NAT cloud routes in Shared Hub. | `number` | `64514` | no |
+| hub\_nat\_enabled | Toggle creation of NAT cloud router in Shared Hub. | `bool` | `false` | no |
+| hub\_nat\_num\_addresses\_region1 | Number of external IPs to reserve for first Cloud NAT in Shared Hub. | `number` | `2` | no |
+| hub\_nat\_num\_addresses\_region2 | Number of external IPs to reserve for second Cloud NAT in Shared Hub. | `number` | `2` | no |
+| hub\_windows\_activation\_enabled | Enable Windows license activation for Windows workloads in Shared Hub. | `bool` | `false` | no |
| ingress\_policies | A list of all [ingress policies](https://cloud.google.com/vpc-service-controls/docs/ingress-egress-rules#ingress-rules-reference), each list object has a `from` and `to` value that describes ingress\_from and ingress\_to.list(object({
from = any
to = any
})) | `[]` | no |
-| perimeter\_additional\_members | The list of additional members to be added to the perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the restricted perimeter, add your user in this list. Entries must be in the standard GCP form: `user:email@example.com` or `serviceAccount:my-service-account@example.com`. | `list(string)` | n/a | yes |
+| perimeter\_additional\_members | The list of additional members to be added to the perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the Shared perimeter, add your user in this list. Entries must be in the standard GCP form: `user:email@example.com` or `serviceAccount:my-service-account@example.com`. | `list(string)` | n/a | yes |
| preactivate\_partner\_interconnect | Preactivate Partner Interconnect VLAN attachment in the environment. | `bool` | `false` | no |
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes |
-| restricted\_hub\_dns\_enable\_inbound\_forwarding | Toggle inbound query forwarding for Restricted Hub VPC DNS. | `bool` | `true` | no |
-| restricted\_hub\_dns\_enable\_logging | Toggle DNS logging for Restricted Hub VPC DNS. | `bool` | `true` | no |
-| restricted\_hub\_firewall\_enable\_logging | Toggle firewall logging for VPC Firewalls in Restricted Hub VPC. | `bool` | `true` | no |
-| restricted\_hub\_nat\_bgp\_asn | BGP ASN for first NAT cloud routes in Restricted Hub. | `number` | `64514` | no |
-| restricted\_hub\_nat\_enabled | Toggle creation of NAT cloud router in Restricted Hub. | `bool` | `false` | no |
-| restricted\_hub\_nat\_num\_addresses\_region1 | Number of external IPs to reserve for first Cloud NAT in Restricted Hub. | `number` | `2` | no |
-| restricted\_hub\_nat\_num\_addresses\_region2 | Number of external IPs to reserve for second Cloud NAT in Restricted Hub. | `number` | `2` | no |
-| restricted\_hub\_windows\_activation\_enabled | Enable Windows license activation for Windows workloads in Restricted Hub. | `bool` | `false` | no |
-| restricted\_vpc\_flow\_logs | enable\_logging: set to true to enable VPC flow logging for the subnetworks.object({
enable_logging = optional(string, "true")
aggregation_interval = optional(string, "INTERVAL_5_SEC")
flow_sampling = optional(string, "0.5")
metadata = optional(string, "INCLUDE_ALL_METADATA")
metadata_fields = optional(list(string), [])
filter_expr = optional(string, "true")
}) | `{}` | no |
| target\_name\_server\_addresses | List of IPv4 address of target name servers for the forwarding zone configuration. See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones for details on target name servers in the context of Cloud DNS forwarding zones. | `list(map(any))` | n/a | yes |
| tfc\_org\_name | Name of the TFC organization | `string` | `""` | no |
+| vpc\_flow\_logs | enable\_logging: set to true to enable VPC flow logging for the subnetworks.object({
enable_logging = optional(string, "true")
aggregation_interval = optional(string, "INTERVAL_5_SEC")
flow_sampling = optional(string, "0.5")
metadata = optional(string, "INCLUDE_ALL_METADATA")
metadata_fields = optional(list(string), [])
filter_expr = optional(string, "true")
}) | `{}` | no |
## Outputs
| Name | Description |
|------|-------------|
-| base\_dns\_policy | The name of the DNS policy being created |
-| base\_host\_project\_id | The base host project ID |
-| base\_network\_name | The name of the VPC being created |
-| restricted\_dns\_policy | The name of the DNS policy being created |
-| restricted\_host\_project\_id | The restricted host project ID |
-| restricted\_network\_name | The name of the VPC being created |
+| dns\_policy | The name of the DNS policy being created |
+| network\_name | The name of the Shared VPC being created |
+| shared\_vpc\_host\_project\_id | The host project ID |
diff --git a/3-networks-hub-and-spoke/envs/shared/interconnect.tf.example b/3-networks-hub-and-spoke/envs/shared/interconnect.tf.example
index c4486e270..eecb19003 100644
--- a/3-networks-hub-and-spoke/envs/shared/interconnect.tf.example
+++ b/3-networks-hub-and-spoke/envs/shared/interconnect.tf.example
@@ -15,20 +15,20 @@
*/
-module "shared_restricted_interconnect" {
+module "shared_vpc_interconnect" {
source = "../../modules/dedicated_interconnect"
- vpc_name = "c-shared-restricted"
- interconnect_project_id = local.restricted_net_hub_project_id
+ vpc_name = "c-svpc"
+ interconnect_project_id = local.net_hub_project_id
region1 = local.default_region1
- region1_router1_name = module.restricted_shared_vpc.region1_router1.router.name
+ region1_router1_name = module.shared_vpc.region1_router1.router.name
region1_interconnect1_candidate_subnets = ["169.254.0.32/29"]
region1_interconnect1_vlan_tag8021q = "3921"
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-dc-1"
- region1_router2_name = module.restricted_shared_vpc.region1_router2.router.name
+ region1_router2_name = module.shared_vpc.region1_router2.router.name
region1_interconnect2_candidate_subnets = ["169.254.0.40/29"]
region1_interconnect2_vlan_tag8021q = "3922"
region1_interconnect2 = "https://www.googleapis.com/compute/v1/projects/${local.interconnect_project_id}/global/interconnects/example-interconnect-2"
@@ -36,13 +36,13 @@ module "shared_restricted_interconnect" {
region1_interconnect2_onprem_dc = "onprem-dc-2"
region2 = local.default_region2
- region2_router1_name = module.restricted_shared_vpc.region2_router1.router.name
+ region2_router1_name = module.shared_vpc.region2_router1.router.name
region2_interconnect1_candidate_subnets = ["169.254.0.48/29"]
region2_interconnect1_vlan_tag8021q = "3923"
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-dc-3"
- region2_router2_name = module.restricted_shared_vpc.region2_router2.router.name
+ region2_router2_name = module.shared_vpc.region2_router2.router.name
region2_interconnect2_candidate_subnets = ["169.254.0.56/29"]
region2_interconnect2_vlan_tag8021q = "3924"
region2_interconnect2 = "https://www.googleapis.com/compute/v1/projects/${local.interconnect_project_id}/global/interconnects/example-interconnect-4"
@@ -60,56 +60,6 @@ module "shared_restricted_interconnect" {
}
depends_on = [
- module.restricted_shared_vpc
- ]
-}
-
-module "shared_base_interconnect" {
- source = "../../modules/dedicated_interconnect"
-
- vpc_name = "c-shared-base"
- interconnect_project_id = local.base_net_hub_project_id
-
- region1 = local.default_region1
- region1_router1_name = module.base_shared_vpc.region1_router1.router.name
- region1_interconnect1_candidate_subnets = ["169.254.0.64/29"]
- region1_interconnect1_vlan_tag8021q = "3925"
- 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-dc-1"
- region1_router2_name = module.base_shared_vpc.region1_router2.router.name
- region1_interconnect2_candidate_subnets = ["169.254.0.72/29"]
- region1_interconnect2_vlan_tag8021q = "3926"
- 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-dc-2"
-
- region2 = local.default_region2
- region2_router1_name = module.base_shared_vpc.region2_router1.router.name
- region2_interconnect1_candidate_subnets = ["169.254.0.80/29"]
- region2_interconnect1_vlan_tag8021q = "3927"
- 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-dc-3"
- region2_router2_name = module.base_shared_vpc.region2_router2.router.name
- region2_interconnect2_candidate_subnets = ["169.254.0.88/29"]
- region2_interconnect2_vlan_tag8021q = "3928"
- 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-dc-4"
-
-
- peer_asn = "64515"
- peer_name = "interconnect-peer"
-
- cloud_router_labels = {
- vlan_1 = "cr1",
- vlan_2 = "cr2",
- vlan_3 = "cr3",
- vlan_4 = "cr4"
- }
-
- depends_on = [
- module.base_shared_vpc
+ module.shared_vpc
]
}
diff --git a/3-networks-hub-and-spoke/envs/shared/net-hubs-transitivity.tf b/3-networks-hub-and-spoke/envs/shared/net-hubs-transitivity.tf
index 049128b09..33ed49752 100644
--- a/3-networks-hub-and-spoke/envs/shared/net-hubs-transitivity.tf
+++ b/3-networks-hub-and-spoke/envs/shared/net-hubs-transitivity.tf
@@ -16,17 +16,8 @@
locals {
enable_transitivity = var.enable_hub_and_spoke_transitivity
- base_regional_aggregates = {
- (local.default_region1) = [
- "10.0.0.0/16",
- "100.64.0.0/16"
- ]
- (local.default_region2) = [
- "10.1.0.0/16",
- "100.65.0.0/16"
- ]
- }
- restricted_regional_aggregates = {
+
+ regional_aggregates = {
(local.default_region1) = [
"10.8.0.0/16",
"100.72.0.0/16"
@@ -39,54 +30,19 @@ locals {
}
/*
- * Base Network Transitivity
- */
-
-module "base_transitivity" {
- source = "../../modules/transitivity"
- count = local.enable_transitivity ? 1 : 0
-
- project_id = local.base_net_hub_project_id
- regions = keys(local.base_subnet_primary_ranges)
- vpc_name = module.base_shared_vpc.network_name
- gw_subnets = { for region in keys(local.base_subnet_primary_ranges) : region => "sb-c-shared-base-hub-${region}" }
- regional_aggregates = local.base_regional_aggregates
- firewall_policy = module.base_shared_vpc.firewall_policy
- commands = [
- # Accept all ICMP (troubleshooting)
- "iptables -A INPUT -p icmp -j ACCEPT",
- # Accept SSH local traffic to the eth0 interface (health checking)
- "iptables -A INPUT -p tcp --dport 22 -d $(curl -H \"Metadata-Flavor: Google\" http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip) -j ACCEPT",
- # Drop everything else
- "iptables -A INPUT -j DROP",
- # Accept all return transit traffic for established flows
- "iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT",
- # Accept all transit traffic from internal ranges
- # Replace by actual multiple source/destination/proto/ports rules for fine-grained ACLs.
- "iptables -A FORWARD -s ${join(",", flatten(values(local.base_regional_aggregates)))} -d ${join(",", flatten(values(local.base_regional_aggregates)))} -j ACCEPT",
- # Drop everything else
- "iptables -A FORWARD -j DROP",
- # SNAT traffic not to the local eth0 interface
- "iptables -t nat -A POSTROUTING ! -d $(curl -H \"Metadata-Flavor: Google\" http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip) -j MASQUERADE",
- ]
-
- depends_on = [module.base_shared_vpc]
-}
-
-/*
- * Restricted Network Transitivity
+ * Network Transitivity
*/
-module "restricted_transitivity" {
+module "network_transitivity" {
source = "../../modules/transitivity"
count = local.enable_transitivity ? 1 : 0
- project_id = local.restricted_net_hub_project_id
- regions = keys(local.restricted_subnet_primary_ranges)
- vpc_name = module.restricted_shared_vpc.network_name
- gw_subnets = { for region in keys(local.restricted_subnet_primary_ranges) : region => "sb-c-shared-restricted-hub-${region}" }
- regional_aggregates = local.restricted_regional_aggregates
- firewall_policy = module.restricted_shared_vpc.firewall_policy
+ project_id = local.net_hub_project_id
+ regions = keys(local.subnet_primary_ranges)
+ vpc_name = module.shared_vpc.network_name
+ gw_subnets = { for region in keys(local.subnet_primary_ranges) : region => "sb-c-svpc-hub-${region}" }
+ regional_aggregates = local.regional_aggregates
+ firewall_policy = module.shared_vpc.firewall_policy
commands = [
# Accept all ICMP (troubleshooting)
"iptables -A INPUT -p icmp -j ACCEPT",
@@ -98,12 +54,12 @@ module "restricted_transitivity" {
"iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT",
# Accept all transit traffic from internal ranges
# Replace by actual multiple source/destination/proto/ports rules for fine-grained ACLs.
- "iptables -A FORWARD -s ${join(",", flatten(values(local.restricted_regional_aggregates)))} -d ${join(",", flatten(values(local.restricted_regional_aggregates)))} -j ACCEPT",
+ "iptables -A FORWARD -s ${join(",", flatten(values(local.regional_aggregates)))} -d ${join(",", flatten(values(local.regional_aggregates)))} -j ACCEPT",
# Drop everything else
"iptables -A FORWARD -j DROP",
# SNAT traffic not to the local eth0 interface
"iptables -t nat -A POSTROUTING ! -d $(curl -H \"Metadata-Flavor: Google\" http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip) -j MASQUERADE",
]
- depends_on = [module.restricted_shared_vpc]
+ depends_on = [module.shared_vpc]
}
diff --git a/3-networks-hub-and-spoke/envs/shared/net-hubs.tf b/3-networks-hub-and-spoke/envs/shared/net-hubs.tf
index dcffa010d..084f7d386 100644
--- a/3-networks-hub-and-spoke/envs/shared/net-hubs.tf
+++ b/3-networks-hub-and-spoke/envs/shared/net-hubs.tf
@@ -15,25 +15,12 @@
*/
locals {
- /*
- * Base network ranges
- */
- base_subnet_primary_ranges = {
- (local.default_region1) = "10.0.0.0/18"
- (local.default_region2) = "10.1.0.0/18"
- }
- base_subnet_proxy_ranges = {
- (local.default_region1) = "10.18.0.0/23"
- (local.default_region2) = "10.19.0.0/23"
- }
- /*
- * Restricted network ranges
- */
- restricted_subnet_primary_ranges = {
+
+ subnet_primary_ranges = {
(local.default_region1) = "10.8.0.0/18"
(local.default_region2) = "10.9.0.0/18"
}
- restricted_subnet_proxy_ranges = {
+ subnet_proxy_ranges = {
(local.default_region1) = "10.26.0.0/23"
(local.default_region2) = "10.27.0.0/23"
}
@@ -168,89 +155,14 @@ locals {
}
/******************************************
- Base Network VPC
-*****************************************/
-
-module "base_shared_vpc" {
- source = "../../modules/base_shared_vpc"
-
- project_id = local.base_net_hub_project_id
- environment_code = local.environment_code
- private_service_connect_ip = "10.17.0.1"
- bgp_asn_subnet = local.bgp_asn_number
- default_region1 = local.default_region1
- default_region2 = local.default_region2
- domain = var.domain
- dns_enable_inbound_forwarding = var.base_hub_dns_enable_inbound_forwarding
- dns_enable_logging = var.base_hub_dns_enable_logging
- firewall_enable_logging = var.base_hub_firewall_enable_logging
- nat_enabled = var.base_hub_nat_enabled
- nat_bgp_asn = var.base_hub_nat_bgp_asn
- nat_num_addresses_region1 = var.base_hub_nat_num_addresses_region1
- nat_num_addresses_region2 = var.base_hub_nat_num_addresses_region2
- windows_activation_enabled = var.base_hub_windows_activation_enabled
- target_name_server_addresses = var.target_name_server_addresses
- mode = "hub"
-
- subnets = [
- {
- subnet_name = "sb-c-shared-base-hub-${local.default_region1}"
- subnet_ip = local.base_subnet_primary_ranges[local.default_region1]
- subnet_region = local.default_region1
- subnet_private_access = "true"
- subnet_flow_logs = var.base_vpc_flow_logs.enable_logging
- subnet_flow_logs_interval = var.base_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.base_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.base_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.base_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.base_vpc_flow_logs.filter_expr
- description = "Base network hub subnet for ${local.default_region1}"
- },
- {
- subnet_name = "sb-c-shared-base-hub-${local.default_region2}"
- subnet_ip = local.base_subnet_primary_ranges[local.default_region2]
- subnet_region = local.default_region2
- subnet_private_access = "true"
- subnet_flow_logs = var.base_vpc_flow_logs.enable_logging
- subnet_flow_logs_interval = var.base_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.base_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.base_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.base_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.base_vpc_flow_logs.filter_expr
- description = "Base network hub subnet for ${local.default_region2}"
- },
- {
- subnet_name = "sb-c-shared-base-hub-${local.default_region1}-proxy"
- subnet_ip = local.base_subnet_proxy_ranges[local.default_region1]
- subnet_region = local.default_region1
- subnet_flow_logs = false
- description = "Base network hub proxy-only subnet for ${local.default_region1}"
- role = "ACTIVE"
- purpose = "REGIONAL_MANAGED_PROXY"
- },
- {
- subnet_name = "sb-c-shared-base-hub-${local.default_region2}-proxy"
- subnet_ip = local.base_subnet_proxy_ranges[local.default_region2]
- subnet_region = local.default_region2
- subnet_flow_logs = false
- description = "Base network hub proxy-only subnet for ${local.default_region2}"
- role = "ACTIVE"
- purpose = "REGIONAL_MANAGED_PROXY"
- }
- ]
- secondary_ranges = {}
-
-}
-
-/******************************************
- Restricted Network VPC
+ Shared Network VPC
*****************************************/
-module "restricted_shared_vpc" {
- source = "../../modules/restricted_shared_vpc"
+module "shared_vpc" {
+ source = "../../modules/shared_vpc"
- project_id = local.restricted_net_hub_project_id
- project_number = local.restricted_net_hub_project_number
+ project_id = local.net_hub_project_id
+ project_number = local.net_hub_project_number
environment_code = local.environment_code
private_service_connect_ip = "10.17.0.5"
access_context_manager_policy_id = var.access_context_manager_policy_id
@@ -270,59 +182,59 @@ module "restricted_shared_vpc" {
default_region1 = local.default_region1
default_region2 = local.default_region2
domain = var.domain
- dns_enable_inbound_forwarding = var.restricted_hub_dns_enable_inbound_forwarding
- dns_enable_logging = var.restricted_hub_dns_enable_logging
- firewall_enable_logging = var.restricted_hub_firewall_enable_logging
- nat_enabled = var.restricted_hub_nat_enabled
- nat_bgp_asn = var.restricted_hub_nat_bgp_asn
- nat_num_addresses_region1 = var.restricted_hub_nat_num_addresses_region1
- nat_num_addresses_region2 = var.restricted_hub_nat_num_addresses_region2
- windows_activation_enabled = var.restricted_hub_windows_activation_enabled
+ dns_enable_inbound_forwarding = var.hub_dns_enable_inbound_forwarding
+ dns_enable_logging = var.hub_dns_enable_logging
+ firewall_enable_logging = var.hub_firewall_enable_logging
+ nat_enabled = var.hub_nat_enabled
+ nat_bgp_asn = var.hub_nat_bgp_asn
+ nat_num_addresses_region1 = var.hub_nat_num_addresses_region1
+ nat_num_addresses_region2 = var.hub_nat_num_addresses_region2
+ windows_activation_enabled = var.hub_windows_activation_enabled
target_name_server_addresses = var.target_name_server_addresses
mode = "hub"
subnets = [
{
- subnet_name = "sb-c-shared-restricted-hub-${local.default_region1}"
- subnet_ip = local.restricted_subnet_primary_ranges[local.default_region1]
+ subnet_name = "sb-c-svpc-hub-${local.default_region1}"
+ subnet_ip = local.subnet_primary_ranges[local.default_region1]
subnet_region = local.default_region1
subnet_private_access = "true"
- subnet_flow_logs = var.restricted_vpc_flow_logs.enable_logging
- subnet_flow_logs_interval = var.restricted_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.restricted_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.restricted_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.restricted_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.restricted_vpc_flow_logs.filter_expr
- description = "Restricted network hub subnet for ${local.default_region1}"
+ subnet_flow_logs = var.vpc_flow_logs.enable_logging
+ subnet_flow_logs_interval = var.vpc_flow_logs.aggregation_interval
+ subnet_flow_logs_sampling = var.vpc_flow_logs.flow_sampling
+ subnet_flow_logs_metadata = var.vpc_flow_logs.metadata
+ subnet_flow_logs_metadata_fields = var.vpc_flow_logs.metadata_fields
+ subnet_flow_logs_filter = var.vpc_flow_logs.filter_expr
+ description = "Network hub subnet for ${local.default_region1}"
},
{
- subnet_name = "sb-c-shared-restricted-hub-${local.default_region2}"
- subnet_ip = local.restricted_subnet_primary_ranges[local.default_region2]
+ subnet_name = "sb-c-svpc-hub-${local.default_region2}"
+ subnet_ip = local.subnet_primary_ranges[local.default_region2]
subnet_region = local.default_region2
subnet_private_access = "true"
- subnet_flow_logs = var.restricted_vpc_flow_logs.enable_logging
- subnet_flow_logs_interval = var.restricted_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.restricted_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.restricted_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.restricted_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.restricted_vpc_flow_logs.filter_expr
- description = "Restricted network hub subnet for ${local.default_region2}"
+ subnet_flow_logs = var.vpc_flow_logs.enable_logging
+ subnet_flow_logs_interval = var.vpc_flow_logs.aggregation_interval
+ subnet_flow_logs_sampling = var.vpc_flow_logs.flow_sampling
+ subnet_flow_logs_metadata = var.vpc_flow_logs.metadata
+ subnet_flow_logs_metadata_fields = var.vpc_flow_logs.metadata_fields
+ subnet_flow_logs_filter = var.vpc_flow_logs.filter_expr
+ description = "Network hub subnet for ${local.default_region2}"
},
{
- subnet_name = "sb-c-shared-restricted-hub-${local.default_region1}-proxy"
- subnet_ip = local.restricted_subnet_proxy_ranges[local.default_region1]
+ subnet_name = "sb-c-svpc-hub-${local.default_region1}-proxy"
+ subnet_ip = local.subnet_proxy_ranges[local.default_region1]
subnet_region = local.default_region1
subnet_flow_logs = false
- description = "Restricted network hub proxy-only subnet for ${local.default_region1}"
+ description = "Network hub proxy-only subnet for ${local.default_region1}"
role = "ACTIVE"
purpose = "REGIONAL_MANAGED_PROXY"
},
{
- subnet_name = "sb-c-shared-restricted-hub-${local.default_region2}-proxy"
- subnet_ip = local.restricted_subnet_proxy_ranges[local.default_region2]
+ subnet_name = "sb-c-svpc-hub-${local.default_region2}-proxy"
+ subnet_ip = local.subnet_proxy_ranges[local.default_region2]
subnet_region = local.default_region2
subnet_flow_logs = false
- description = "Restricted network hub proxy-only subnet for ${local.default_region2}"
+ description = "Network hub proxy-only subnet for ${local.default_region2}"
role = "ACTIVE"
purpose = "REGIONAL_MANAGED_PROXY"
}
diff --git a/3-networks-hub-and-spoke/envs/shared/outputs.tf b/3-networks-hub-and-spoke/envs/shared/outputs.tf
index 6af4101cf..8a633f925 100644
--- a/3-networks-hub-and-spoke/envs/shared/outputs.tf
+++ b/3-networks-hub-and-spoke/envs/shared/outputs.tf
@@ -14,32 +14,17 @@
* limitations under the License.
*/
-output "restricted_host_project_id" {
- value = local.restricted_net_hub_project_id
- description = "The restricted host project ID"
+output "shared_vpc_host_project_id" {
+ value = local.net_hub_project_id
+ description = "The host project ID"
}
-output "base_host_project_id" {
- value = local.base_net_hub_project_id
- description = "The base host project ID"
+output "network_name" {
+ value = module.shared_vpc.network_name
+ description = "The name of the Shared VPC being created"
}
-output "base_network_name" {
- value = module.base_shared_vpc.network_name
- description = "The name of the VPC being created"
-}
-
-output "restricted_network_name" {
- value = module.restricted_shared_vpc.network_name
- description = "The name of the VPC being created"
-}
-
-output "base_dns_policy" {
- value = module.base_shared_vpc.base_dns_policy
- description = "The name of the DNS policy being created"
-}
-
-output "restricted_dns_policy" {
- value = module.restricted_shared_vpc.restricted_dns_policy
+output "dns_policy" {
+ value = module.shared_vpc.dns_policy
description = "The name of the DNS policy being created"
}
diff --git a/3-networks-hub-and-spoke/envs/shared/partner_interconnect.tf.example b/3-networks-hub-and-spoke/envs/shared/partner_interconnect.tf.example
index 92cd21dde..5a37b5122 100644
--- a/3-networks-hub-and-spoke/envs/shared/partner_interconnect.tf.example
+++ b/3-networks-hub-and-spoke/envs/shared/partner_interconnect.tf.example
@@ -15,26 +15,26 @@
*/
-module "shared_restricted_interconnect" {
+module "interconnect" {
source = "../../modules/partner_interconnect"
- attachment_project_id = local.restricted_net_hub_project_id
- vpc_name = "${local.environment_code}-shared-restricted"
+ attachment_project_id = local.net_hub_project_id
+ vpc_name = "${local.environment_code}-svpc"
preactivate = var.preactivate_partner_interconnect
region1 = local.default_region1
- region1_router1_name = module.restricted_shared_vpc.region1_router1.router.name
+ region1_router1_name = module.shared_vpc.region1_router1.router.name
region1_interconnect1_location = "las-zone1-770"
region1_interconnect1_onprem_dc = "onprem-dc1"
- region1_router2_name = module.restricted_shared_vpc.region1_router2.router.name
+ region1_router2_name = module.shared_vpc.region1_router2.router.name
region1_interconnect2_location = "las-zone1-770"
region1_interconnect2_onprem_dc = "onprem-dc2"
region2 = local.default_region2
- region2_router1_name = module.restricted_shared_vpc.region2_router1.router.name
+ region2_router1_name = module.shared_vpc.region2_router1.router.name
region2_interconnect1_location = "lax-zone2-19"
region2_interconnect1_onprem_dc = "onprem-dc3"
- region2_router2_name = module.restricted_shared_vpc.region2_router2.router.name
+ region2_router2_name = module.shared_vpc.region2_router2.router.name
region2_interconnect2_location = "lax-zone1-403"
region2_interconnect2_onprem_dc = "onprem-dc4"
@@ -45,34 +45,3 @@ module "shared_restricted_interconnect" {
vlan_4 = "cr8"
}
}
-
-module "shared_base_interconnect" {
- source = "../../modules/partner_interconnect"
-
- attachment_project_id = local.base_net_hub_project_id
- vpc_name = "${local.environment_code}-shared-base"
- preactivate = var.preactivate_partner_interconnect
-
- region1 = local.default_region1
- region1_router1_name = module.base_shared_vpc.region1_router1.router.name
- region1_interconnect1_location = "las-zone1-770"
- region1_interconnect1_onprem_dc = "onprem-dc1"
- region1_router2_name = module.base_shared_vpc.region1_router2.router.name
- region1_interconnect2_location = "las-zone1-770"
- region1_interconnect2_onprem_dc = "onprem-dc2"
-
- region2 = local.default_region2
- region2_router1_name = module.base_shared_vpc.region2_router1.router.name
- region2_interconnect1_location = "lax-zone2-19"
- region2_interconnect1_onprem_dc = "onprem-dc3"
- region2_router2_name = module.base_shared_vpc.region2_router2.router.name
- region2_interconnect2_location = "lax-zone1-403"
- region2_interconnect2_onprem_dc = "onprem-dc4"
-
- cloud_router_labels = {
- vlan_1 = "cr1",
- vlan_2 = "cr2",
- vlan_3 = "cr3",
- vlan_4 = "cr4"
- }
-}
diff --git a/3-networks-hub-and-spoke/envs/shared/remote.tf b/3-networks-hub-and-spoke/envs/shared/remote.tf
index 78e898578..490877bd6 100644
--- a/3-networks-hub-and-spoke/envs/shared/remote.tf
+++ b/3-networks-hub-and-spoke/envs/shared/remote.tf
@@ -15,29 +15,28 @@
*/
locals {
- interconnect_project_id = data.terraform_remote_state.org.outputs.interconnect_project_id
- interconnect_project_number = data.terraform_remote_state.org.outputs.interconnect_project_number
- parent_folder = data.terraform_remote_state.bootstrap.outputs.common_config.parent_folder
- org_id = data.terraform_remote_state.bootstrap.outputs.common_config.org_id
- billing_account = data.terraform_remote_state.bootstrap.outputs.common_config.billing_account
- default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
- default_region1 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
- default_region2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
- project_prefix = data.terraform_remote_state.bootstrap.outputs.common_config.project_prefix
- folder_prefix = data.terraform_remote_state.bootstrap.outputs.common_config.folder_prefix
- parent_id = data.terraform_remote_state.bootstrap.outputs.common_config.parent_id
- bootstrap_folder_name = data.terraform_remote_state.bootstrap.outputs.common_config.bootstrap_folder_name
- common_folder_name = data.terraform_remote_state.org.outputs.common_folder_name
- network_folder_name = data.terraform_remote_state.org.outputs.network_folder_name
- development_folder_name = data.terraform_remote_state.env_development.outputs.env_folder
- nonproduction_folder_name = data.terraform_remote_state.env_nonproduction.outputs.env_folder
- production_folder_name = data.terraform_remote_state.env_production.outputs.env_folder
- base_net_hub_project_id = data.terraform_remote_state.org.outputs.base_net_hub_project_id
- restricted_net_hub_project_id = data.terraform_remote_state.org.outputs.restricted_net_hub_project_id
- restricted_net_hub_project_number = data.terraform_remote_state.org.outputs.restricted_net_hub_project_number
- organization_service_account = data.terraform_remote_state.bootstrap.outputs.organization_step_terraform_service_account_email
- networks_service_account = data.terraform_remote_state.bootstrap.outputs.networks_step_terraform_service_account_email
- projects_service_account = data.terraform_remote_state.bootstrap.outputs.projects_step_terraform_service_account_email
+ interconnect_project_id = data.terraform_remote_state.org.outputs.interconnect_project_id
+ interconnect_project_number = data.terraform_remote_state.org.outputs.interconnect_project_number
+ parent_folder = data.terraform_remote_state.bootstrap.outputs.common_config.parent_folder
+ org_id = data.terraform_remote_state.bootstrap.outputs.common_config.org_id
+ billing_account = data.terraform_remote_state.bootstrap.outputs.common_config.billing_account
+ default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
+ default_region1 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region
+ default_region2 = data.terraform_remote_state.bootstrap.outputs.common_config.default_region_2
+ project_prefix = data.terraform_remote_state.bootstrap.outputs.common_config.project_prefix
+ folder_prefix = data.terraform_remote_state.bootstrap.outputs.common_config.folder_prefix
+ parent_id = data.terraform_remote_state.bootstrap.outputs.common_config.parent_id
+ bootstrap_folder_name = data.terraform_remote_state.bootstrap.outputs.common_config.bootstrap_folder_name
+ common_folder_name = data.terraform_remote_state.org.outputs.common_folder_name
+ network_folder_name = data.terraform_remote_state.org.outputs.network_folder_name
+ development_folder_name = data.terraform_remote_state.env_development.outputs.env_folder
+ nonproduction_folder_name = data.terraform_remote_state.env_nonproduction.outputs.env_folder
+ production_folder_name = data.terraform_remote_state.env_production.outputs.env_folder
+ net_hub_project_id = data.terraform_remote_state.org.outputs.net_hub_project_id
+ net_hub_project_number = data.terraform_remote_state.org.outputs.net_hub_project_number
+ organization_service_account = data.terraform_remote_state.bootstrap.outputs.organization_step_terraform_service_account_email
+ networks_service_account = data.terraform_remote_state.bootstrap.outputs.networks_step_terraform_service_account_email
+ projects_service_account = data.terraform_remote_state.bootstrap.outputs.projects_step_terraform_service_account_email
}
data "terraform_remote_state" "bootstrap" {
diff --git a/3-networks-hub-and-spoke/envs/shared/remote.tf.cloud.example b/3-networks-hub-and-spoke/envs/shared/remote.tf.cloud.example
index f609c65e4..9eda763db 100644
--- a/3-networks-hub-and-spoke/envs/shared/remote.tf.cloud.example
+++ b/3-networks-hub-and-spoke/envs/shared/remote.tf.cloud.example
@@ -30,11 +30,10 @@ locals {
common_folder_name = data.tfe_outputs.org.nonsensitive_values.common_folder_name
network_folder_name = data.tfe_outputs.org.nonsensitive_values.network_folder_name
development_folder_name = data.tfe_outputs.env_development.nonsensitive_values.env_folder
- nonproduction_folder_name = data.tfe_outputs.env_nonproduction.nonsensitive_values.env_folder
+ nonproduction_folder_name = data.tfe_outputs.env_nonproduction.nonsensitive_values.env_folder
production_folder_name = data.tfe_outputs.env_production.nonsensitive_values.env_folder
- base_net_hub_project_id = data.tfe_outputs.org.nonsensitive_values.base_net_hub_project_id
- restricted_net_hub_project_id = data.tfe_outputs.org.nonsensitive_values.restricted_net_hub_project_id
- restricted_net_hub_project_number = data.tfe_outputs.org.nonsensitive_values.restricted_net_hub_project_number
+ net_hub_project_id = data.tfe_outputs.org.nonsensitive_values.net_hub_project_id
+ net_hub_project_number = data.tfe_outputs.org.nonsensitive_values.net_hub_project_number
organization_service_account = data.tfe_outputs.bootstrap.nonsensitive_values.organization_step_terraform_service_account_email
networks_service_account = data.tfe_outputs.bootstrap.nonsensitive_values.networks_step_terraform_service_account_email
projects_service_account = data.tfe_outputs.bootstrap.nonsensitive_values.projects_step_terraform_service_account_email
diff --git a/3-networks-hub-and-spoke/envs/shared/variables.tf b/3-networks-hub-and-spoke/envs/shared/variables.tf
index 65f70ee84..42bcc7530 100644
--- a/3-networks-hub-and-spoke/envs/shared/variables.tf
+++ b/3-networks-hub-and-spoke/envs/shared/variables.tf
@@ -20,7 +20,7 @@ variable "remote_state_bucket" {
}
variable "perimeter_additional_members" {
- description = "The list of additional members to be added to the perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the restricted perimeter, add your user in this list. Entries must be in the standard GCP form: `user:email@example.com` or `serviceAccount:my-service-account@example.com`."
+ description = "The list of additional members to be added to the perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the Shared perimeter, add your user in this list. Entries must be in the standard GCP form: `user:email@example.com` or `serviceAccount:my-service-account@example.com`."
type = list(string)
}
@@ -71,123 +71,55 @@ variable "target_name_server_addresses" {
type = list(map(any))
}
-variable "base_hub_windows_activation_enabled" {
+variable "hub_windows_activation_enabled" {
type = bool
- description = "Enable Windows license activation for Windows workloads in Base Hub"
+ description = "Enable Windows license activation for Windows workloads in Shared Hub."
default = false
}
-variable "restricted_hub_windows_activation_enabled" {
+variable "hub_dns_enable_inbound_forwarding" {
type = bool
- description = "Enable Windows license activation for Windows workloads in Restricted Hub."
- default = false
-}
-
-variable "base_hub_dns_enable_inbound_forwarding" {
- type = bool
- description = "Toggle inbound query forwarding for Base Hub VPC DNS."
- default = true
-}
-
-variable "restricted_hub_dns_enable_inbound_forwarding" {
- type = bool
- description = "Toggle inbound query forwarding for Restricted Hub VPC DNS."
- default = true
-}
-
-variable "base_hub_dns_enable_logging" {
- type = bool
- description = "Toggle DNS logging for Base Hub VPC DNS."
- default = true
-}
-
-variable "restricted_hub_dns_enable_logging" {
- type = bool
- description = "Toggle DNS logging for Restricted Hub VPC DNS."
+ description = "Toggle inbound query forwarding for Shared Hub VPC DNS."
default = true
}
-variable "base_hub_firewall_enable_logging" {
+variable "hub_dns_enable_logging" {
type = bool
- description = "Toggle firewall logging for VPC Firewalls in Base Hub VPC."
+ description = "Toggle DNS logging for Shared Hub VPC DNS."
default = true
}
-variable "restricted_hub_firewall_enable_logging" {
+variable "hub_firewall_enable_logging" {
type = bool
- description = "Toggle firewall logging for VPC Firewalls in Restricted Hub VPC."
+ description = "Toggle firewall logging for VPC Firewalls in Shared Hub VPC."
default = true
}
-variable "base_hub_nat_enabled" {
- type = bool
- description = "Toggle creation of NAT cloud router in Base Hub."
- default = false
-}
-
-variable "restricted_hub_nat_enabled" {
+variable "hub_nat_enabled" {
type = bool
- description = "Toggle creation of NAT cloud router in Restricted Hub."
+ description = "Toggle creation of NAT cloud router in Shared Hub."
default = false
}
-variable "base_hub_nat_bgp_asn" {
+variable "hub_nat_bgp_asn" {
type = number
- description = "BGP ASN for first NAT cloud routes in Base Hub."
+ description = "BGP ASN for first NAT cloud routes in Shared Hub."
default = 64514
}
-variable "restricted_hub_nat_bgp_asn" {
+variable "hub_nat_num_addresses_region1" {
type = number
- description = "BGP ASN for first NAT cloud routes in Restricted Hub."
- default = 64514
-}
-
-variable "base_hub_nat_num_addresses_region1" {
- type = number
- description = "Number of external IPs to reserve for first Cloud NAT in Base Hub."
+ description = "Number of external IPs to reserve for first Cloud NAT in Shared Hub."
default = 2
}
-variable "restricted_hub_nat_num_addresses_region1" {
+variable "hub_nat_num_addresses_region2" {
type = number
- description = "Number of external IPs to reserve for first Cloud NAT in Restricted Hub."
+ description = "Number of external IPs to reserve for second Cloud NAT in Shared Hub."
default = 2
}
-variable "base_hub_nat_num_addresses_region2" {
- type = number
- description = "Number of external IPs to reserve for second Cloud NAT in Base Hub."
- default = 2
-}
-
-variable "restricted_hub_nat_num_addresses_region2" {
- type = number
- description = "Number of external IPs to reserve for second Cloud NAT in Restricted Hub."
- default = 2
-}
-
-variable "base_vpc_flow_logs" {
- description = <object({
aggregation_interval = optional(string, "INTERVAL_5_SEC")
flow_sampling = optional(string, "0.5")
metadata = optional(string, "INCLUDE_ALL_METADATA")
metadata_fields = optional(list(string), [])
filter_expr = optional(string, "true")
}) | `{}` | no |
| custom\_restricted\_services | List of custom services to be protected by the enforced VPC-SC perimeter. If empty, all supported services (https://cloud.google.com/vpc-service-controls/docs/supported-products) will be protected. | `list(string)` | `[]` | no |
| custom\_restricted\_services\_dry\_run | List of custom services to be protected by the dry-run VPC-SC perimeter. If empty, all supported services (https://cloud.google.com/vpc-service-controls/docs/supported-products) will be protected. | `list(string)` | `[]` | no |
| default\_region1 | First subnet region. The shared vpc modules only configures two regions. | `string` | n/a | yes |
@@ -26,15 +20,15 @@
| ingress\_policies\_dry\_run | A list of all [ingress policies](https://cloud.google.com/vpc-service-controls/docs/ingress-egress-rules#ingress-rules-reference) to use in a dry-run perimeter. Each list object has a `from` and `to` value that describes ingress\_from and ingress\_to.list(object({
from = any
to = any
})) | `[]` | no |
| perimeter\_additional\_members | The list of additional members to be added to the enforced perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the restricted perimeter, add your user in this list. Entries must be in the standard GCP form: `user:email@example.com` or `serviceAccount:my-service-account@example.com`. | `list(string)` | `[]` | no |
| perimeter\_additional\_members\_dry\_run | The list of additional members to be added to the dry-run perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the restricted perimeter, add your user in this list. Entries must be in the standard GCP form: `user:email@example.com` or `serviceAccount:my-service-account@example.com`. | `list(string)` | `[]` | no |
+| private\_service\_cidr | CIDR range for private service networking. Used for Cloud SQL and other managed services in the Shared Vpc. | `string` | n/a | yes |
+| private\_service\_connect\_ip | The subnet internal IP to be used as the private service connect endpoint in the Shared VPC | `string` | n/a | yes |
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes |
-| restricted\_private\_service\_cidr | CIDR range for private service networking. Used for Cloud SQL and other managed services in the Restricted Shared Vpc. | `string` | n/a | yes |
-| restricted\_private\_service\_connect\_ip | The base subnet internal IP to be used as the private service connect endpoint in the Restricted Shared VPC | `string` | n/a | yes |
-| restricted\_subnet\_primary\_ranges | The base subnet primary IPTs ranges to the Restricted Shared Vpc. | `map(string)` | n/a | yes |
-| restricted\_subnet\_proxy\_ranges | The base proxy-only subnet primary IPTs ranges to the Restricted Shared Vpc. | `map(string)` | n/a | yes |
-| restricted\_subnet\_secondary\_ranges | The base subnet secondary IPTs ranges to the Restricted Shared Vpc | `map(list(map(string)))` | n/a | yes |
-| restricted\_vpc\_flow\_logs | aggregation\_interval: Toggles the aggregation interval for collecting flow logs. Increasing the interval time will reduce the amount of generated flow logs for long lasting connections. Possible values are: INTERVAL\_5\_SEC, INTERVAL\_30\_SEC, INTERVAL\_1\_MIN, INTERVAL\_5\_MIN, INTERVAL\_10\_MIN, INTERVAL\_15\_MIN.object({
aggregation_interval = optional(string, "INTERVAL_5_SEC")
flow_sampling = optional(string, "0.5")
metadata = optional(string, "INCLUDE_ALL_METADATA")
metadata_fields = optional(list(string), [])
filter_expr = optional(string, "true")
}) | `{}` | no |
+| subnet\_primary\_ranges | The subnet primary IPTs ranges to the Shared Vpc. | `map(string)` | n/a | yes |
+| subnet\_proxy\_ranges | The proxy-only subnet primary IPTs ranges to the Shared Vpc. | `map(string)` | n/a | yes |
+| subnet\_secondary\_ranges | The subnet secondary IPTs ranges to the Shared Vpc | `map(list(map(string)))` | n/a | yes |
| target\_name\_server\_addresses | List of IPv4 address of target name servers for the forwarding zone configuration. See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones for details on target name servers in the context of Cloud DNS forwarding zones. | `list(map(any))` | `[]` | no |
| tfc\_org\_name | Name of the TFC organization | `string` | n/a | yes |
+| vpc\_flow\_logs | aggregation\_interval: Toggles the aggregation interval for collecting flow logs. Increasing the interval time will reduce the amount of generated flow logs for long lasting connections. Possible values are: INTERVAL\_5\_SEC, INTERVAL\_30\_SEC, INTERVAL\_1\_MIN, INTERVAL\_5\_MIN, INTERVAL\_10\_MIN, INTERVAL\_15\_MIN.object({
aggregation_interval = optional(string, "INTERVAL_5_SEC")
flow_sampling = optional(string, "0.5")
metadata = optional(string, "INCLUDE_ALL_METADATA")
metadata_fields = optional(list(string), [])
filter_expr = optional(string, "true")
}) | `{}` | no |
## Outputs
@@ -42,22 +36,15 @@
|------|-------------|
| access\_level\_name | Access context manager access level name for the enforced perimeter |
| access\_level\_name\_dry\_run | Access context manager access level name for the dry-run perimeter |
-| base\_host\_project\_id | The base host project ID |
-| base\_network\_name | The name of the VPC being created |
-| base\_network\_self\_link | The URI of the VPC being created |
-| base\_subnets\_ips | The IPs and CIDRs of the subnets being created |
-| base\_subnets\_names | The names of the subnets being created |
-| base\_subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
-| base\_subnets\_self\_links | The self-links of subnets being created |
| enforce\_vpcsc | Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases. |
-| restricted\_host\_project\_id | The restricted host project ID |
-| restricted\_network\_name | The name of the VPC being created |
-| restricted\_network\_self\_link | The URI of the VPC being created |
-| restricted\_service\_perimeter\_name | Access context manager service perimeter name for the enforced perimeter |
-| restricted\_subnets\_ips | The IPs and CIDRs of the subnets being created |
-| restricted\_subnets\_names | The names of the subnets being created |
-| restricted\_subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
-| restricted\_subnets\_self\_links | The self-links of subnets being created |
+| network\_name | The name of the VPC being created |
+| network\_self\_link | The URI of the VPC being created |
+| service\_perimeter\_name | Access context manager service perimeter name for the enforced perimeter |
+| shared\_vpc\_host\_project\_id | The host project ID |
+| subnets\_ips | The IPs and CIDRs of the subnets being created |
+| subnets\_names | The names of the subnets being created |
+| subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
+| subnets\_self\_links | The self-links of subnets being created |
| target\_name\_server\_addresses | List of IPv4 address of target name servers for the forwarding zone configuration |
diff --git a/3-networks-hub-and-spoke/modules/base_env/main.tf b/3-networks-hub-and-spoke/modules/base_env/main.tf
index a50e05619..60e34e5af 100644
--- a/3-networks-hub-and-spoke/modules/base_env/main.tf
+++ b/3-networks-hub-and-spoke/modules/base_env/main.tf
@@ -18,16 +18,8 @@ locals {
bgp_asn_number = var.enable_partner_interconnect ? "16550" : "64514"
enable_transitivity = var.enable_hub_and_spoke_transitivity
- /*
- * Base network ranges
- */
- base_subnet_aggregates = ["10.0.0.0/18", "10.1.0.0/18", "100.64.0.0/18", "100.65.0.0/18"]
- base_hub_subnet_ranges = ["10.0.0.0/24", "10.1.0.0/24"]
- /*
- * Restricted network ranges
- */
- restricted_subnet_aggregates = ["10.8.0.0/18", "10.9.0.0/18", "100.72.0.0/18", "100.73.0.0/18"]
- restricted_hub_subnet_ranges = ["10.8.0.0/24", "10.9.0.0/24"]
+ subnet_aggregates = ["10.8.0.0/18", "10.9.0.0/18", "100.72.0.0/18", "100.73.0.0/18"]
+ hub_subnet_ranges = ["10.8.0.0/24", "10.9.0.0/24"]
supported_restricted_service = [
"accessapproval.googleapis.com",
@@ -159,19 +151,19 @@ locals {
}
/******************************************
- Restricted shared VPC
+ Shared VPC
*****************************************/
-module "restricted_shared_vpc" {
- source = "../restricted_shared_vpc"
+module "shared_vpc" {
+ source = "../shared_vpc"
- project_id = local.restricted_project_id
- project_number = local.restricted_project_number
- restricted_net_hub_project_id = local.restricted_net_hub_project_id
- restricted_net_hub_project_number = local.restricted_net_hub_project_number
- environment_code = var.environment_code
- access_context_manager_policy_id = var.access_context_manager_policy_id
- restricted_services = local.restricted_services
- restricted_services_dry_run = local.restricted_services_dry_run
+ project_id = local.shared_vpc_project_id
+ project_number = local.shared_vpc_project_number
+ net_hub_project_id = local.net_hub_project_id
+ net_hub_project_number = local.net_hub_project_number
+ environment_code = var.environment_code
+ access_context_manager_policy_id = var.access_context_manager_policy_id
+ restricted_services = local.restricted_services
+ restricted_services_dry_run = local.restricted_services_dry_run
members = distinct(concat([
"serviceAccount:${local.networks_service_account}",
"serviceAccount:${local.projects_service_account}",
@@ -182,8 +174,8 @@ module "restricted_shared_vpc" {
"serviceAccount:${local.projects_service_account}",
"serviceAccount:${local.organization_service_account}",
], var.perimeter_additional_members))
- private_service_cidr = var.restricted_private_service_cidr
- private_service_connect_ip = var.restricted_private_service_connect_ip
+ private_service_cidr = var.private_service_cidr
+ private_service_connect_ip = var.private_service_connect_ip
ingress_policies = var.ingress_policies
egress_policies = var.egress_policies
bgp_asn_subnet = local.bgp_asn_number
@@ -195,34 +187,34 @@ module "restricted_shared_vpc" {
subnets = [
{
- subnet_name = "sb-${var.environment_code}-shared-restricted-${var.default_region1}"
- subnet_ip = var.restricted_subnet_primary_ranges[var.default_region1]
+ subnet_name = "sb-${var.environment_code}-svpc-${var.default_region1}"
+ subnet_ip = var.subnet_primary_ranges[var.default_region1]
subnet_region = var.default_region1
subnet_private_access = "true"
subnet_flow_logs = true
- subnet_flow_logs_interval = var.restricted_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.restricted_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.restricted_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.restricted_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.restricted_vpc_flow_logs.filter_expr
+ subnet_flow_logs_interval = var.vpc_flow_logs.aggregation_interval
+ subnet_flow_logs_sampling = var.vpc_flow_logs.flow_sampling
+ subnet_flow_logs_metadata = var.vpc_flow_logs.metadata
+ subnet_flow_logs_metadata_fields = var.vpc_flow_logs.metadata_fields
+ subnet_flow_logs_filter = var.vpc_flow_logs.filter_expr
description = "First ${var.env} subnet example."
},
{
- subnet_name = "sb-${var.environment_code}-shared-restricted-${var.default_region2}"
- subnet_ip = var.restricted_subnet_primary_ranges[var.default_region2]
+ subnet_name = "sb-${var.environment_code}-svpc-${var.default_region2}"
+ subnet_ip = var.subnet_primary_ranges[var.default_region2]
subnet_region = var.default_region2
subnet_private_access = "true"
subnet_flow_logs = true
- subnet_flow_logs_interval = var.restricted_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.restricted_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.restricted_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.restricted_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.restricted_vpc_flow_logs.filter_expr
+ subnet_flow_logs_interval = var.vpc_flow_logs.aggregation_interval
+ subnet_flow_logs_sampling = var.vpc_flow_logs.flow_sampling
+ subnet_flow_logs_metadata = var.vpc_flow_logs.metadata
+ subnet_flow_logs_metadata_fields = var.vpc_flow_logs.metadata_fields
+ subnet_flow_logs_filter = var.vpc_flow_logs.filter_expr
description = "Second ${var.env} subnet example."
},
{
- subnet_name = "sb-${var.environment_code}-shared-restricted-${var.default_region1}-proxy"
- subnet_ip = var.restricted_subnet_proxy_ranges[var.default_region1]
+ subnet_name = "sb-${var.environment_code}-svpc-${var.default_region1}-proxy"
+ subnet_ip = var.subnet_proxy_ranges[var.default_region1]
subnet_region = var.default_region1
subnet_flow_logs = false
description = "First ${var.env} proxy-only subnet example."
@@ -230,8 +222,8 @@ module "restricted_shared_vpc" {
purpose = "REGIONAL_MANAGED_PROXY"
},
{
- subnet_name = "sb-${var.environment_code}-shared-restricted-${var.default_region2}-proxy"
- subnet_ip = var.restricted_subnet_proxy_ranges[var.default_region2]
+ subnet_name = "sb-${var.environment_code}-svpc-${var.default_region2}-proxy"
+ subnet_ip = var.subnet_proxy_ranges[var.default_region2]
subnet_region = var.default_region2
subnet_flow_logs = false
description = "Second ${var.env} proxy-only subnet example."
@@ -240,76 +232,6 @@ module "restricted_shared_vpc" {
}
]
secondary_ranges = {
- "sb-${var.environment_code}-shared-restricted-${var.default_region1}" = var.restricted_subnet_secondary_ranges[var.default_region1]
- }
-}
-
-/******************************************
- Base shared VPC
-*****************************************/
-
-module "base_shared_vpc" {
- source = "../base_shared_vpc"
-
- project_id = local.base_project_id
- base_net_hub_project_id = local.base_net_hub_project_id
- environment_code = var.environment_code
- private_service_cidr = var.base_private_service_cidr
- private_service_connect_ip = var.base_private_service_connect_ip
- default_region1 = var.default_region1
- default_region2 = var.default_region2
- domain = var.domain
- bgp_asn_subnet = local.bgp_asn_number
- mode = "spoke"
- target_name_server_addresses = var.target_name_server_addresses
-
- subnets = [
- {
- subnet_name = "sb-${var.environment_code}-shared-base-${var.default_region1}"
- subnet_ip = var.base_subnet_primary_ranges[var.default_region1]
- subnet_region = var.default_region1
- subnet_private_access = "true"
- subnet_flow_logs = true
- subnet_flow_logs_interval = var.base_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.base_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.base_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.base_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.base_vpc_flow_logs.filter_expr
- description = "First ${var.env} subnet example."
- },
- {
- subnet_name = "sb-${var.environment_code}-shared-base-${var.default_region2}"
- subnet_ip = var.base_subnet_primary_ranges[var.default_region2]
- subnet_region = var.default_region2
- subnet_private_access = "true"
- subnet_flow_logs = true
- subnet_flow_logs_interval = var.base_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.base_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.base_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.base_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.base_vpc_flow_logs.filter_expr
- description = "Second ${var.env} subnet example."
- },
- {
- subnet_name = "sb-${var.environment_code}-shared-base-${var.default_region1}-proxy"
- subnet_ip = var.base_subnet_proxy_ranges[var.default_region1]
- subnet_region = var.default_region1
- description = "First ${var.env} proxy-only subnet example."
- subnet_flow_logs = false
- role = "ACTIVE"
- purpose = "REGIONAL_MANAGED_PROXY"
- },
- {
- subnet_name = "sb-${var.environment_code}-shared-base-${var.default_region2}-proxy"
- subnet_ip = var.base_subnet_proxy_ranges[var.default_region2]
- subnet_region = var.default_region2
- description = "Second ${var.env} proxy-only subnet example."
- subnet_flow_logs = false
- role = "ACTIVE"
- purpose = "REGIONAL_MANAGED_PROXY"
- }
- ]
- secondary_ranges = {
- "sb-${var.environment_code}-shared-base-${var.default_region1}" = var.base_subnet_secondary_ranges[var.default_region1]
+ "sb-${var.environment_code}-svpc-${var.default_region1}" = var.subnet_secondary_ranges[var.default_region1]
}
}
diff --git a/3-networks-hub-and-spoke/modules/base_env/outputs.tf b/3-networks-hub-and-spoke/modules/base_env/outputs.tf
index 053c1c134..e4e7217d9 100644
--- a/3-networks-hub-and-spoke/modules/base_env/outputs.tf
+++ b/3-networks-hub-and-spoke/modules/base_env/outputs.tf
@@ -19,102 +19,57 @@ output "target_name_server_addresses" {
description = "List of IPv4 address of target name servers for the forwarding zone configuration"
}
-/*********************
- Restricted Outputs
-*********************/
-
-output "restricted_host_project_id" {
- value = local.restricted_project_id
- description = "The restricted host project ID"
+output "shared_vpc_host_project_id" {
+ value = local.shared_vpc_project_id
+ description = "The host project ID"
}
-output "restricted_network_name" {
- value = module.restricted_shared_vpc.network_name
+output "network_name" {
+ value = module.shared_vpc.network_name
description = "The name of the VPC being created"
}
-output "restricted_network_self_link" {
- value = module.restricted_shared_vpc.network_self_link
+output "network_self_link" {
+ value = module.shared_vpc.network_self_link
description = "The URI of the VPC being created"
}
-output "restricted_subnets_names" {
- value = module.restricted_shared_vpc.subnets_names
+output "subnets_names" {
+ value = module.shared_vpc.subnets_names
description = "The names of the subnets being created"
}
-output "restricted_subnets_ips" {
- value = module.restricted_shared_vpc.subnets_ips
+output "subnets_ips" {
+ value = module.shared_vpc.subnets_ips
description = "The IPs and CIDRs of the subnets being created"
}
-output "restricted_subnets_self_links" {
- value = module.restricted_shared_vpc.subnets_self_links
+output "subnets_self_links" {
+ value = module.shared_vpc.subnets_self_links
description = "The self-links of subnets being created"
}
-output "restricted_subnets_secondary_ranges" {
- value = module.restricted_shared_vpc.subnets_secondary_ranges
+output "subnets_secondary_ranges" {
+ value = module.shared_vpc.subnets_secondary_ranges
description = "The secondary ranges associated with these subnets"
}
output "access_level_name" {
- value = module.restricted_shared_vpc.access_level_name
+ value = module.shared_vpc.access_level_name
description = "Access context manager access level name for the enforced perimeter"
}
output "access_level_name_dry_run" {
- value = module.restricted_shared_vpc.access_level_name_dry_run
+ value = module.shared_vpc.access_level_name_dry_run
description = "Access context manager access level name for the dry-run perimeter"
}
output "enforce_vpcsc" {
- value = module.restricted_shared_vpc.enforce_vpcsc
+ value = module.shared_vpc.enforce_vpcsc
description = "Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases."
}
-output "restricted_service_perimeter_name" {
- value = module.restricted_shared_vpc.service_perimeter_name
+output "service_perimeter_name" {
+ value = module.shared_vpc.service_perimeter_name
description = "Access context manager service perimeter name for the enforced perimeter"
}
-
-
-
-/******************************************
- Private Outputs
-*****************************************/
-
-output "base_host_project_id" {
- value = local.base_project_id
- description = "The base host project ID"
-}
-
-output "base_network_name" {
- value = module.base_shared_vpc.network_name
- description = "The name of the VPC being created"
-}
-
-output "base_network_self_link" {
- value = module.base_shared_vpc.network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "base_subnets_names" {
- value = module.base_shared_vpc.subnets_names
- description = "The names of the subnets being created"
-}
-
-output "base_subnets_ips" {
- value = module.base_shared_vpc.subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "base_subnets_self_links" {
- value = module.base_shared_vpc.subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "base_subnets_secondary_ranges" {
- value = module.base_shared_vpc.subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
diff --git a/3-networks-hub-and-spoke/modules/base_env/remote.tf b/3-networks-hub-and-spoke/modules/base_env/remote.tf
index 8a6e50259..535fbeb03 100644
--- a/3-networks-hub-and-spoke/modules/base_env/remote.tf
+++ b/3-networks-hub-and-spoke/modules/base_env/remote.tf
@@ -15,15 +15,13 @@
*/
locals {
- restricted_project_id = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].restricted_shared_vpc_project_id
- restricted_project_number = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].restricted_shared_vpc_project_number
- base_project_id = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].base_shared_vpc_project_id
- base_net_hub_project_id = data.terraform_remote_state.org.outputs.base_net_hub_project_id
- restricted_net_hub_project_id = data.terraform_remote_state.org.outputs.restricted_net_hub_project_id
- restricted_net_hub_project_number = data.terraform_remote_state.org.outputs.restricted_net_hub_project_number
- organization_service_account = data.terraform_remote_state.bootstrap.outputs.organization_step_terraform_service_account_email
- networks_service_account = data.terraform_remote_state.bootstrap.outputs.networks_step_terraform_service_account_email
- projects_service_account = data.terraform_remote_state.bootstrap.outputs.projects_step_terraform_service_account_email
+ shared_vpc_project_id = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].shared_vpc_project_id
+ shared_vpc_project_number = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].shared_vpc_project_number
+ net_hub_project_id = data.terraform_remote_state.org.outputs.net_hub_project_id
+ net_hub_project_number = data.terraform_remote_state.org.outputs.net_hub_project_number
+ organization_service_account = data.terraform_remote_state.bootstrap.outputs.organization_step_terraform_service_account_email
+ networks_service_account = data.terraform_remote_state.bootstrap.outputs.networks_step_terraform_service_account_email
+ projects_service_account = data.terraform_remote_state.bootstrap.outputs.projects_step_terraform_service_account_email
}
data "terraform_remote_state" "bootstrap" {
diff --git a/3-networks-hub-and-spoke/modules/base_env/remote.tf.cloud.example b/3-networks-hub-and-spoke/modules/base_env/remote.tf.cloud.example
index 05eefabbe..c8e364f67 100644
--- a/3-networks-hub-and-spoke/modules/base_env/remote.tf.cloud.example
+++ b/3-networks-hub-and-spoke/modules/base_env/remote.tf.cloud.example
@@ -15,12 +15,10 @@
*/
locals {
- restricted_project_id = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].restricted_shared_vpc_project_id
- restricted_project_number = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].restricted_shared_vpc_project_number
- base_project_id = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].base_shared_vpc_project_id
- base_net_hub_project_id = data.tfe_outputs.org.nonsensitive_values.base_net_hub_project_id
- restricted_net_hub_project_id = data.tfe_outputs.org.nonsensitive_values.restricted_net_hub_project_id
- restricted_net_hub_project_number = data.tfe_outputs.org.nonsensitive_values.restricted_net_hub_project_number
+ project_id = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].project_id
+ project_number = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].shared_vpc_project_number
+ net_hub_project_id = data.tfe_outputs.org.nonsensitive_values.net_hub_project_id
+ net_hub_project_number = data.tfe_outputs.org.nonsensitive_values.net_hub_project_number
organization_service_account = data.tfe_outputs.bootstrap.nonsensitive_values.organization_step_terraform_service_account_email
networks_service_account = data.tfe_outputs.bootstrap.nonsensitive_values.networks_step_terraform_service_account_email
projects_service_account = data.tfe_outputs.bootstrap.nonsensitive_values.projects_step_terraform_service_account_email
diff --git a/3-networks-hub-and-spoke/modules/base_env/variables.tf b/3-networks-hub-and-spoke/modules/base_env/variables.tf
index aa4cdef97..3c9ce405c 100644
--- a/3-networks-hub-and-spoke/modules/base_env/variables.tf
+++ b/3-networks-hub-and-spoke/modules/base_env/variables.tf
@@ -73,75 +73,32 @@ variable "enable_hub_and_spoke_transitivity" {
default = false
}
-variable "base_private_service_cidr" {
+variable "private_service_cidr" {
type = string
- description = "CIDR range for private service networking. Used for Cloud SQL and other managed services in the Base Shared Vpc."
+ description = "CIDR range for private service networking. Used for Cloud SQL and other managed services in the Shared Vpc."
}
-variable "base_subnet_primary_ranges" {
+variable "subnet_primary_ranges" {
type = map(string)
- description = "The base subnet primary IPTs ranges to the Base Shared Vpc."
+ description = "The subnet primary IPTs ranges to the Shared Vpc."
}
-variable "base_subnet_proxy_ranges" {
+variable "subnet_proxy_ranges" {
type = map(string)
- description = "The base proxy-only subnet primary IPTs ranges to the Base Shared Vpc."
+ description = "The proxy-only subnet primary IPTs ranges to the Shared Vpc."
}
-variable "base_subnet_secondary_ranges" {
+variable "subnet_secondary_ranges" {
type = map(list(map(string)))
- description = "The base subnet secondary IPTs ranges to the Base Shared Vpc."
+ description = "The subnet secondary IPTs ranges to the Shared Vpc"
}
-variable "base_private_service_connect_ip" {
+variable "private_service_connect_ip" {
type = string
- description = "The base subnet internal IP to be used as the private service connect endpoint in the Base Shared VPC"
+ description = "The subnet internal IP to be used as the private service connect endpoint in the Shared VPC"
}
-variable "base_vpc_flow_logs" {
- description = <list(object({
subnet_name = string
subnet_ip = string
subnet_region = string
subnet_private_access = optional(string, "false")
subnet_private_ipv6_access = optional(string)
subnet_flow_logs = optional(string, "false")
subnet_flow_logs_interval = optional(string, "INTERVAL_5_SEC")
subnet_flow_logs_sampling = optional(string, "0.5")
subnet_flow_logs_metadata = optional(string, "INCLUDE_ALL_METADATA")
subnet_flow_logs_filter = optional(string, "true")
subnet_flow_logs_metadata_fields = optional(list(string), [])
description = optional(string)
purpose = optional(string)
role = optional(string)
stack_type = optional(string)
ipv6_access_type = optional(string)
})) | `[]` | no |
-| target\_name\_server\_addresses | List of IPv4 address of target name servers for the forwarding zone configuration. See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones for details on target name servers in the context of Cloud DNS forwarding zones. | `list(map(any))` | n/a | yes |
-| windows\_activation\_enabled | Enable Windows license activation for Windows workloads. | `bool` | `false` | no |
-
-## Outputs
-
-| Name | Description |
-|------|-------------|
-| base\_dns\_policy | The name of the DNS policy being created |
-| firewall\_policy | Policy created for firewall policy rules. |
-| network\_name | The name of the VPC being created |
-| network\_self\_link | The URI of the VPC being created |
-| region1\_router1 | Router 1 for Region 1 |
-| region1\_router2 | Router 2 for Region 1 |
-| region2\_router1 | Router 1 for Region 2 |
-| region2\_router2 | Router 2 for Region 2 |
-| subnets\_flow\_logs | Whether the subnets have VPC flow logs enabled |
-| subnets\_ips | The IPs and CIDRs of the subnets being created |
-| subnets\_names | The names of the subnets being created |
-| subnets\_private\_access | Whether the subnets have access to Google API's without a public IP |
-| subnets\_regions | The region where the subnets will be created |
-| subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
-| subnets\_self\_links | The self-links of subnets being created |
-
-
diff --git a/3-networks-hub-and-spoke/modules/base_shared_vpc/firewall.tf b/3-networks-hub-and-spoke/modules/base_shared_vpc/firewall.tf
deleted file mode 100644
index 94dbe7b31..000000000
--- a/3-networks-hub-and-spoke/modules/base_shared_vpc/firewall.tf
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/******************************************
- Mandatory and optional firewall rules
- *****************************************/
-module "firewall_rules" {
- source = "terraform-google-modules/network/google//modules/network-firewall-policy"
- version = "~> 10.0"
-
- project_id = var.project_id
- policy_name = "fp-${var.environment_code}-hub-and-spoke-base-firewalls"
- description = "Firewall rules for base hub and spoke shared vpc: ${module.main.network_name}."
- target_vpcs = ["projects/${var.project_id}/global/networks/${module.main.network_name}"]
-
- rules = concat(
- [
- {
- priority = "65530"
- direction = "EGRESS"
- action = "deny"
- rule_name = "fw-${var.environment_code}-shared-base-65530-e-d-all-all-all"
- description = "Lower priority rule to deny all egress traffic."
- enable_logging = var.firewall_enable_logging
- match = {
- dest_ip_ranges = ["0.0.0.0/0"]
- layer4_configs = [
- {
- ip_protocol = "all"
- },
- ]
- }
- },
- {
- priority = "1000"
- direction = "EGRESS"
- action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-1000-e-a-allow-google-apis-all-tcp-443"
- description = "Lower priority rule to allow private google apis on TCP port 443."
- enable_logging = var.firewall_enable_logging
- match = {
- dest_ip_ranges = [local.private_googleapis_cidr]
- layer4_configs = [
- {
- ip_protocol = "tcp"
- ports = ["443"]
- },
- ]
- }
- }
- ],
- !var.enable_all_vpc_internal_traffic ? [] : [
- {
- priority = "10000"
- direction = "EGRESS"
- action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-10000-e-a-all-all-all"
- description = "Allow all egress to the provided IP range."
- enable_logging = var.firewall_enable_logging
- match = {
- dest_ip_ranges = module.main.subnets_ips
- layer4_configs = [
- {
- ip_protocol = "all"
- },
- ]
- }
- }
- ],
- !var.enable_all_vpc_internal_traffic ? [] : [
- {
- priority = "10001"
- direction = "INGRESS"
- action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-10001-i-a-all"
- description = "Allow all ingress to the provided IP range."
- enable_logging = var.firewall_enable_logging
- match = {
- src_ip_ranges = module.main.subnets_ips
- layer4_configs = [
- {
- ip_protocol = "all"
- },
- ]
- }
- }
- ]
- )
-}
diff --git a/3-networks-hub-and-spoke/modules/base_shared_vpc/main.tf b/3-networks-hub-and-spoke/modules/base_shared_vpc/main.tf
deleted file mode 100644
index 5be4fb015..000000000
--- a/3-networks-hub-and-spoke/modules/base_shared_vpc/main.tf
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-locals {
- mode = var.mode == null ? "" : var.mode == "hub" ? "-hub" : "-spoke"
- vpc_name = "${var.environment_code}-shared-base${local.mode}"
- network_name = "vpc-${local.vpc_name}"
- private_googleapis_cidr = module.private_service_connect.private_service_connect_ip
- google_forward_source_range = "35.199.192.0/19"
- advertised_ip = var.environment_code == "c" ? [{ range = local.google_forward_source_range }, { range = local.private_googleapis_cidr }] : [{ range = local.private_googleapis_cidr }]
-
-}
-
-/******************************************
- Shared VPC configuration
- *****************************************/
-
-module "main" {
- source = "terraform-google-modules/network/google"
- version = "~> 10.0"
-
- project_id = var.project_id
- network_name = local.network_name
- shared_vpc_host = "true"
- delete_default_internet_gateway_routes = "true"
-
- subnets = var.subnets
- secondary_ranges = var.secondary_ranges
-
- routes = concat(
- var.nat_enabled ?
- [
- {
- name = "rt-${local.vpc_name}-1000-egress-internet-default"
- description = "Tag based route through IGW to access internet"
- destination_range = "0.0.0.0/0"
- tags = "egress-internet"
- next_hop_internet = "true"
- priority = "1000"
- }
- ]
- : [],
- var.windows_activation_enabled ?
- [{
- name = "rt-${local.vpc_name}-1000-all-default-windows-kms"
- description = "Route through IGW to allow Windows KMS activation for GCP."
- destination_range = "35.190.247.13/32"
- next_hop_internet = "true"
- priority = "1000"
- }
- ]
- : []
- )
-}
-
-/***************************************************************
- VPC Peering Configuration
- **************************************************************/
-data "google_compute_network" "vpc_base_net_hub" {
- count = var.mode == "spoke" ? 1 : 0
- name = "vpc-c-shared-base-hub"
- project = var.base_net_hub_project_id
-}
-
-module "peering" {
- source = "terraform-google-modules/network/google//modules/network-peering"
- version = "~> 10.0"
- count = var.mode == "spoke" ? 1 : 0
-
- prefix = "np"
- local_network = module.main.network_self_link
- peer_network = data.google_compute_network.vpc_base_net_hub[0].self_link
- export_peer_custom_routes = true
-}
-
-/***************************************************************
- Configure Service Networking for Cloud SQL & future services.
- **************************************************************/
-
-resource "google_compute_global_address" "private_service_access_address" {
- count = var.private_service_cidr != null ? 1 : 0
- name = "ga-${local.vpc_name}-vpc-peering-internal"
- project = var.project_id
- purpose = "VPC_PEERING"
- address_type = "INTERNAL"
- address = element(split("/", var.private_service_cidr), 0)
- prefix_length = element(split("/", var.private_service_cidr), 1)
- network = module.main.network_self_link
-
- depends_on = [module.peering]
-}
-
-resource "google_service_networking_connection" "private_vpc_connection" {
- count = var.private_service_cidr != null ? 1 : 0
- network = module.main.network_self_link
- service = "servicenetworking.googleapis.com"
- reserved_peering_ranges = [google_compute_global_address.private_service_access_address[0].name]
-
- depends_on = [module.peering]
-}
-
-/************************************
- Router to advertise shared VPC
- subnetworks and Google Private API
-************************************/
-
-module "region1_router1" {
- source = "terraform-google-modules/cloud-router/google"
- version = "~> 6.0"
- count = var.mode != "spoke" ? 1 : 0
-
- name = "cr-${local.vpc_name}-${var.default_region1}-cr1"
- project = var.project_id
- network = module.main.network_name
- region = var.default_region1
- bgp = {
- asn = var.bgp_asn_subnet
- advertised_groups = ["ALL_SUBNETS"]
- advertised_ip_ranges = local.advertised_ip
- }
-}
-
-module "region1_router2" {
- source = "terraform-google-modules/cloud-router/google"
- version = "~> 6.0"
- count = var.mode != "spoke" ? 1 : 0
-
- name = "cr-${local.vpc_name}-${var.default_region1}-cr2"
- project = var.project_id
- network = module.main.network_name
- region = var.default_region1
- bgp = {
- asn = var.bgp_asn_subnet
- advertised_groups = ["ALL_SUBNETS"]
- advertised_ip_ranges = local.advertised_ip
- }
-}
-
-module "region2_router1" {
- source = "terraform-google-modules/cloud-router/google"
- version = "~> 6.0"
- count = var.mode != "spoke" ? 1 : 0
-
- name = "cr-${local.vpc_name}-${var.default_region2}-cr3"
- project = var.project_id
- network = module.main.network_name
- region = var.default_region2
- bgp = {
- asn = var.bgp_asn_subnet
- advertised_groups = ["ALL_SUBNETS"]
- advertised_ip_ranges = local.advertised_ip
- }
-}
-
-module "region2_router2" {
- source = "terraform-google-modules/cloud-router/google"
- version = "~> 6.0"
- count = var.mode != "spoke" ? 1 : 0
-
- name = "cr-${local.vpc_name}-${var.default_region2}-cr4"
- project = var.project_id
- network = module.main.network_name
- region = var.default_region2
- bgp = {
- asn = var.bgp_asn_subnet
- advertised_groups = ["ALL_SUBNETS"]
- advertised_ip_ranges = local.advertised_ip
- }
-}
diff --git a/3-networks-hub-and-spoke/modules/base_shared_vpc/nat.tf b/3-networks-hub-and-spoke/modules/base_shared_vpc/nat.tf
deleted file mode 100644
index dc0b49c4d..000000000
--- a/3-networks-hub-and-spoke/modules/base_shared_vpc/nat.tf
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/******************************************
- NAT Cloud Router & NAT config
- *****************************************/
-
-resource "google_compute_router" "nat_router_region1" {
- count = var.nat_enabled ? 1 : 0
- name = "cr-${local.vpc_name}-${var.default_region1}-nat-router"
- project = var.project_id
- region = var.default_region1
- network = module.main.network_self_link
-
- bgp {
- asn = var.nat_bgp_asn
- }
-}
-
-resource "google_compute_address" "nat_external_addresses_region1" {
- count = var.nat_enabled ? var.nat_num_addresses_region1 : 0
- project = var.project_id
- name = "ca-${local.vpc_name}-${var.default_region1}-${count.index}"
- region = var.default_region1
-}
-
-resource "google_compute_router_nat" "egress_nat_region1" {
- count = var.nat_enabled ? 1 : 0
- name = "rn-${local.vpc_name}-${var.default_region1}-egress"
- project = var.project_id
- router = google_compute_router.nat_router_region1[0].name
- region = var.default_region1
- nat_ip_allocate_option = "MANUAL_ONLY"
- nat_ips = google_compute_address.nat_external_addresses_region1.*.self_link
- source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
-
- log_config {
- filter = "TRANSLATIONS_ONLY"
- enable = true
- }
-}
-
-resource "google_compute_router" "nat_router_region2" {
- count = var.nat_enabled ? 1 : 0
- name = "cr-${local.vpc_name}-${var.default_region2}-nat-router"
- project = var.project_id
- region = var.default_region2
- network = module.main.network_self_link
-
- bgp {
- asn = var.nat_bgp_asn
- }
-}
-
-resource "google_compute_address" "nat_external_addresses_region2" {
- count = var.nat_enabled ? var.nat_num_addresses_region2 : 0
- project = var.project_id
- name = "ca-${local.vpc_name}-${var.default_region2}-${count.index}"
- region = var.default_region2
-}
-
-resource "google_compute_router_nat" "egress_nat2" {
- count = var.nat_enabled ? 1 : 0
- name = "rn-${local.vpc_name}-${var.default_region2}-egress"
- project = var.project_id
- router = google_compute_router.nat_router_region2[0].name
- region = var.default_region2
- nat_ip_allocate_option = "MANUAL_ONLY"
- nat_ips = google_compute_address.nat_external_addresses_region2.*.self_link
- source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
-
- log_config {
- filter = "TRANSLATIONS_ONLY"
- enable = true
- }
-}
diff --git a/3-networks-hub-and-spoke/modules/base_shared_vpc/outputs.tf b/3-networks-hub-and-spoke/modules/base_shared_vpc/outputs.tf
deleted file mode 100644
index 3d13190d7..000000000
--- a/3-networks-hub-and-spoke/modules/base_shared_vpc/outputs.tf
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-output "network_name" {
- value = module.main.network_name
- description = "The name of the VPC being created"
-}
-
-output "base_dns_policy" {
- value = google_dns_policy.default_policy.name
- description = "The name of the DNS policy being created"
-}
-
-output "network_self_link" {
- value = module.main.network_self_link
- description = "The URI of the VPC being created"
-}
-
-output "subnets_names" {
- value = module.main.subnets_names
- description = "The names of the subnets being created"
-}
-
-output "subnets_ips" {
- value = module.main.subnets_ips
- description = "The IPs and CIDRs of the subnets being created"
-}
-
-output "subnets_self_links" {
- value = module.main.subnets_self_links
- description = "The self-links of subnets being created"
-}
-
-output "subnets_regions" {
- value = module.main.subnets_regions
- description = "The region where the subnets will be created"
-}
-
-output "subnets_private_access" {
- value = module.main.subnets_private_access
- description = "Whether the subnets have access to Google API's without a public IP"
-}
-
-output "subnets_flow_logs" {
- value = module.main.subnets_flow_logs
- description = "Whether the subnets have VPC flow logs enabled"
-}
-
-output "subnets_secondary_ranges" {
- value = module.main.subnets_secondary_ranges
- description = "The secondary ranges associated with these subnets"
-}
-
-output "region1_router1" {
- value = try(module.region1_router1[0], null)
- description = "Router 1 for Region 1"
-}
-
-output "region1_router2" {
- value = try(module.region1_router2[0], null)
- description = "Router 2 for Region 1"
-}
-
-output "region2_router1" {
- value = try(module.region2_router1[0], null)
- description = "Router 1 for Region 2"
-}
-
-output "region2_router2" {
- value = try(module.region2_router2[0], null)
- description = "Router 2 for Region 2"
-}
-
-output "firewall_policy" {
- value = module.firewall_rules.fw_policy[0].name
- description = "Policy created for firewall policy rules."
-}
diff --git a/3-networks-hub-and-spoke/modules/base_shared_vpc/private_service_connect.tf b/3-networks-hub-and-spoke/modules/base_shared_vpc/private_service_connect.tf
deleted file mode 100644
index c18e514e6..000000000
--- a/3-networks-hub-and-spoke/modules/base_shared_vpc/private_service_connect.tf
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-module "private_service_connect" {
- source = "terraform-google-modules/network/google//modules/private-service-connect"
- version = "~> 10.0"
-
- project_id = var.project_id
- dns_code = "dz-${var.environment_code}-shared-base"
- network_self_link = module.main.network_self_link
- private_service_connect_ip = var.private_service_connect_ip
- forwarding_rule_target = "all-apis"
-}
diff --git a/3-networks-hub-and-spoke/modules/base_shared_vpc/variables.tf b/3-networks-hub-and-spoke/modules/base_shared_vpc/variables.tf
deleted file mode 100644
index ed45d3a9a..000000000
--- a/3-networks-hub-and-spoke/modules/base_shared_vpc/variables.tf
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-variable "target_name_server_addresses" {
- description = "List of IPv4 address of target name servers for the forwarding zone configuration. See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones for details on target name servers in the context of Cloud DNS forwarding zones."
- type = list(map(any))
-}
-
-variable "project_id" {
- type = string
- description = "Project ID for Private Shared VPC."
-}
-
-variable "base_net_hub_project_id" {
- type = string
- description = "The base net hub project ID"
- default = ""
-}
-
-variable "mode" {
- type = string
- description = "Network deployment mode, should be set to `hub` or `spoke` when `enable_hub_and_spoke` architecture chosen, keep as `null` otherwise."
- default = null
-}
-
-variable "environment_code" {
- type = string
- description = "A short form of the folder level resources (environment) within the Google Cloud organization."
-}
-
-variable "default_region1" {
- type = string
- description = "Default region 1 for subnets and Cloud Routers"
-}
-
-variable "default_region2" {
- type = string
- description = "Default region 2 for subnets and Cloud Routers"
-}
-
-variable "nat_enabled" {
- type = bool
- description = "Toggle creation of NAT cloud router."
- default = false
-}
-
-variable "nat_bgp_asn" {
- type = number
- description = "BGP ASN for first NAT cloud routes."
- default = 64514
-}
-
-variable "nat_num_addresses_region1" {
- type = number
- description = "Number of external IPs to reserve for first Cloud NAT."
- default = 2
-}
-
-variable "nat_num_addresses_region2" {
- type = number
- description = "Number of external IPs to reserve for second Cloud NAT."
- default = 2
-}
-
-variable "bgp_asn_subnet" {
- type = number
- description = "BGP ASN for Subnets cloud routers."
-}
-
-variable "subnets" {
- type = list(object({
- subnet_name = string
- subnet_ip = string
- subnet_region = string
- subnet_private_access = optional(string, "false")
- subnet_private_ipv6_access = optional(string)
- subnet_flow_logs = optional(string, "false")
- subnet_flow_logs_interval = optional(string, "INTERVAL_5_SEC")
- subnet_flow_logs_sampling = optional(string, "0.5")
- subnet_flow_logs_metadata = optional(string, "INCLUDE_ALL_METADATA")
- subnet_flow_logs_filter = optional(string, "true")
- subnet_flow_logs_metadata_fields = optional(list(string), [])
- description = optional(string)
- purpose = optional(string)
- role = optional(string)
- stack_type = optional(string)
- ipv6_access_type = optional(string)
- }))
- description = "The list of subnets being created"
- default = []
-}
-
-variable "secondary_ranges" {
- type = map(list(object({ range_name = string, ip_cidr_range = string })))
- description = "Secondary ranges that will be used in some of the subnets"
- default = {}
-}
-
-variable "dns_enable_inbound_forwarding" {
- type = bool
- description = "Toggle inbound query forwarding for VPC DNS."
- default = true
-}
-
-variable "dns_enable_logging" {
- type = bool
- description = "Toggle DNS logging for VPC DNS."
- default = true
-}
-
-variable "firewall_enable_logging" {
- type = bool
- description = "Toggle firewall logging for VPC Firewalls."
- default = true
-}
-
-variable "domain" {
- type = string
- description = "The DNS name of peering managed zone, for instance 'example.com.'"
-}
-
-variable "private_service_cidr" {
- type = string
- description = "CIDR range for private service networking. Used for Cloud SQL and other managed services."
- default = null
-}
-
-variable "private_service_connect_ip" {
- type = string
- description = "Internal IP to be used as the private service connect endpoint."
-}
-
-variable "windows_activation_enabled" {
- type = bool
- description = "Enable Windows license activation for Windows workloads."
- default = false
-}
-
-variable "enable_all_vpc_internal_traffic" {
- type = bool
- description = "Enable firewall policy rule to allow internal traffic (ingress and egress)."
- default = false
-}
-
-variable "enable_transitivity_traffic" {
- type = bool
- description = "Enable a firewall policy rule to allow traffic between Hub and Spokes (ingress only)."
- default = true
-}
diff --git a/3-networks-hub-and-spoke/modules/base_shared_vpc/versions.tf b/3-networks-hub-and-spoke/modules/base_shared_vpc/versions.tf
deleted file mode 100644
index bcffc4274..000000000
--- a/3-networks-hub-and-spoke/modules/base_shared_vpc/versions.tf
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-terraform {
- required_version = ">= 0.13"
- required_providers {
- google = {
- source = "hashicorp/google"
- version = ">= 3.50"
- }
- google-beta = {
- source = "hashicorp/google-beta"
- version = ">= 3.50"
- }
- }
-
- provider_meta "google" {
- module_name = "blueprints/terraform/terraform-example-foundation:base_shared_vpc/v4.1.0"
- }
-
- provider_meta "google-beta" {
- module_name = "blueprints/terraform/terraform-example-foundation:base_shared_vpc/v4.1.0"
- }
-}
diff --git a/3-networks-hub-and-spoke/modules/dedicated_interconnect/versions.tf b/3-networks-hub-and-spoke/modules/dedicated_interconnect/versions.tf
index 4b50cfdd2..e0f5555f4 100644
--- a/3-networks-hub-and-spoke/modules/dedicated_interconnect/versions.tf
+++ b/3-networks-hub-and-spoke/modules/dedicated_interconnect/versions.tf
@@ -18,12 +18,14 @@ terraform {
required_version = ">= 0.13"
required_providers {
google = {
+ // version 6.26.0 removed because of the bug https://github.com/hashicorp/terraform-provider-google/issues/21950
source = "hashicorp/google"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
google-beta = {
+ // version 6.26.0 removed because of the bug https://github.com/hashicorp/terraform-provider-google/issues/21950
source = "hashicorp/google-beta"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
}
diff --git a/3-networks-hub-and-spoke/modules/hierarchical_firewall_policy/versions.tf b/3-networks-hub-and-spoke/modules/hierarchical_firewall_policy/versions.tf
index 8f6a8235a..3101ab902 100644
--- a/3-networks-hub-and-spoke/modules/hierarchical_firewall_policy/versions.tf
+++ b/3-networks-hub-and-spoke/modules/hierarchical_firewall_policy/versions.tf
@@ -18,12 +18,14 @@ terraform {
required_version = ">= 0.13"
required_providers {
google = {
+ // version 6.26.0 removed because of the bug https://github.com/hashicorp/terraform-provider-google/issues/21950
source = "hashicorp/google"
- version = ">= 3.82"
+ version = ">= 3.82, < 6.26.0"
}
google-beta = {
+ // version 6.26.0 removed because of the bug https://github.com/hashicorp/terraform-provider-google/issues/21950
source = "hashicorp/google-beta"
- version = ">= 3.82"
+ version = ">= 3.82, < 6.26.0"
}
random = {
source = "hashicorp/random"
diff --git a/3-networks-hub-and-spoke/modules/partner_interconnect/README.md b/3-networks-hub-and-spoke/modules/partner_interconnect/README.md
index 5eb809ad6..1a9005cd2 100644
--- a/3-networks-hub-and-spoke/modules/partner_interconnect/README.md
+++ b/3-networks-hub-and-spoke/modules/partner_interconnect/README.md
@@ -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-net-dns` 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-svpc-net-hub` and `prj-net-dns` under the folder `fldr-common` in case of Hub and Spoke architecture.
## Usage
diff --git a/3-networks-hub-and-spoke/modules/partner_interconnect/versions.tf b/3-networks-hub-and-spoke/modules/partner_interconnect/versions.tf
index e363eb942..7eb80374d 100644
--- a/3-networks-hub-and-spoke/modules/partner_interconnect/versions.tf
+++ b/3-networks-hub-and-spoke/modules/partner_interconnect/versions.tf
@@ -18,12 +18,14 @@ terraform {
required_version = ">= 0.13"
required_providers {
google = {
+ // version 6.26.0 removed because of the bug https://github.com/hashicorp/terraform-provider-google/issues/21950
source = "hashicorp/google"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
google-beta = {
+ // version 6.26.0 removed because of the bug https://github.com/hashicorp/terraform-provider-google/issues/21950
source = "hashicorp/google-beta"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
}
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/dns.tf b/3-networks-hub-and-spoke/modules/restricted_shared_vpc/dns.tf
deleted file mode 100644
index e9dadbb59..000000000
--- a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/dns.tf
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Copyright 2022 Google LLC
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/******************************************
- Default DNS Policy
- *****************************************/
-
-resource "google_dns_policy" "default_policy" {
- project = var.project_id
- name = "dp-${var.environment_code}-shared-restricted-default-policy"
- enable_inbound_forwarding = var.dns_enable_inbound_forwarding
- enable_logging = var.dns_enable_logging
- networks {
- network_url = module.main.network_self_link
- }
-}
-
-/******************************************
- Creates DNS Peering to DNS HUB
-*****************************************/
-
-module "peering_zone" {
- source = "terraform-google-modules/cloud-dns/google"
- version = "~> 5.0"
-
- count = var.mode == "spoke" ? 1 : 0
-
- project_id = var.project_id
- type = "peering"
- name = "dz-${var.environment_code}-shared-restricted-to-dns-hub"
- domain = var.domain
- description = "Private DNS peering zone."
-
- private_visibility_config_networks = [
- module.main.network_self_link
- ]
- target_network = data.google_compute_network.vpc_restricted_net_hub[0].self_link
-}
-
-/******************************************
- DNS Forwarding
-*****************************************/
-module "dns_forwarding_zone" {
- source = "terraform-google-modules/cloud-dns/google"
- version = "~> 5.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.main.network_self_link
- ]
- target_name_server_addresses = var.target_name_server_addresses
-}
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/README.md b/3-networks-hub-and-spoke/modules/shared_vpc/README.md
similarity index 95%
rename from 3-networks-hub-and-spoke/modules/restricted_shared_vpc/README.md
rename to 3-networks-hub-and-spoke/modules/shared_vpc/README.md
index 130845c51..74c4627d9 100644
--- a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/README.md
+++ b/3-networks-hub-and-spoke/modules/shared_vpc/README.md
@@ -26,12 +26,12 @@
| nat\_enabled | Toggle creation of NAT cloud router. | `bool` | `false` | no |
| nat\_num\_addresses\_region1 | Number of external IPs to reserve for region 1 Cloud NAT. | `number` | `2` | no |
| nat\_num\_addresses\_region2 | Number of external IPs to reserve for region 2 Cloud NAT. | `number` | `2` | no |
+| net\_hub\_project\_id | The net hub project ID | `string` | `""` | no |
+| net\_hub\_project\_number | The net hub project number | `string` | `""` | no |
| private\_service\_cidr | CIDR range for private service networking. Used for Cloud SQL and other managed services. | `string` | `null` | no |
| private\_service\_connect\_ip | Internal IP to be used as the private service connect endpoint. | `string` | n/a | yes |
-| project\_id | Project ID for Restricted Shared VPC. | `string` | n/a | yes |
-| project\_number | Project number for Restricted Shared VPC. It is the project INSIDE the regular service perimeter. | `number` | n/a | yes |
-| restricted\_net\_hub\_project\_id | The restricted net hub project ID | `string` | `""` | no |
-| restricted\_net\_hub\_project\_number | The restricted net hub project number | `string` | `""` | no |
+| project\_id | Project ID for Shared VPC. | `string` | n/a | yes |
+| project\_number | Project number for Shared VPC. | `number` | n/a | yes |
| restricted\_services | List of services to restrict in an enforced perimeter. | `list(string)` | n/a | yes |
| restricted\_services\_dry\_run | List of services to restrict in a dry-run perimeter. | `list(string)` | n/a | yes |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no |
@@ -45,6 +45,7 @@
|------|-------------|
| access\_level\_name | Access context manager access level name for the enforced perimeter |
| access\_level\_name\_dry\_run | Access context manager access level name for the dry-run perimeter |
+| dns\_policy | The name of the DNS policy being created |
| enforce\_vpcsc | Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases. |
| firewall\_policy | Policy created for firewall policy rules. |
| network\_name | The name of the VPC being created |
@@ -53,7 +54,6 @@
| region1\_router2 | Router 2 for Region 1 |
| region2\_router1 | Router 1 for Region 2 |
| region2\_router2 | Router 2 for Region 2 |
-| restricted\_dns\_policy | The name of the DNS policy being created |
| service\_perimeter\_name | Access context manager service perimeter name for the enforced perimeter |
| subnets\_ips | The IPs and CIDRs of the subnets being created |
| subnets\_names | The names of the subnets being created |
diff --git a/3-networks-hub-and-spoke/modules/base_shared_vpc/dns.tf b/3-networks-hub-and-spoke/modules/shared_vpc/dns.tf
similarity index 89%
rename from 3-networks-hub-and-spoke/modules/base_shared_vpc/dns.tf
rename to 3-networks-hub-and-spoke/modules/shared_vpc/dns.tf
index 355031822..657467d8c 100644
--- a/3-networks-hub-and-spoke/modules/base_shared_vpc/dns.tf
+++ b/3-networks-hub-and-spoke/modules/shared_vpc/dns.tf
@@ -20,7 +20,7 @@
resource "google_dns_policy" "default_policy" {
project = var.project_id
- name = "dp-${var.environment_code}-shared-base-default-policy"
+ name = "dp-${var.environment_code}-svpc-default-policy"
enable_inbound_forwarding = var.dns_enable_inbound_forwarding
enable_logging = var.dns_enable_logging
networks {
@@ -40,14 +40,14 @@ module "peering_zone" {
project_id = var.project_id
type = "peering"
- name = "dz-${var.environment_code}-shared-base-to-dns-hub"
+ name = "dz-${var.environment_code}-svpc-to-dns-hub"
domain = var.domain
description = "Private DNS peering zone."
private_visibility_config_networks = [
module.main.network_self_link
]
- target_network = data.google_compute_network.vpc_base_net_hub[0].self_link
+ target_network = data.google_compute_network.vpc_net_hub[0].self_link
}
/******************************************
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/firewall.tf b/3-networks-hub-and-spoke/modules/shared_vpc/firewall.tf
similarity index 83%
rename from 3-networks-hub-and-spoke/modules/restricted_shared_vpc/firewall.tf
rename to 3-networks-hub-and-spoke/modules/shared_vpc/firewall.tf
index 5e2a9be25..d8a311090 100644
--- a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/firewall.tf
+++ b/3-networks-hub-and-spoke/modules/shared_vpc/firewall.tf
@@ -23,8 +23,8 @@ module "firewall_rules" {
version = "~> 10.0"
project_id = var.project_id
- policy_name = "fp-${var.environment_code}-hub-and-spoke-restricted-firewalls"
- description = "Firewall rules for restricted hub and spoke shared vpc: ${module.main.network_name}."
+ policy_name = "fp-${var.environment_code}-hub-and-spoke-firewalls"
+ description = "Firewall rules for hub and spoke shared vpc: ${module.main.network_name}."
target_vpcs = ["projects/${var.project_id}/global/networks/${module.main.network_name}"]
rules = concat(
@@ -33,7 +33,7 @@ module "firewall_rules" {
priority = "65530"
direction = "EGRESS"
action = "deny"
- rule_name = "fw-${var.environment_code}-shared-restricted-65530-e-d-all-all-all"
+ rule_name = "fw-${var.environment_code}-svpc-65530-e-d-all-all-all"
description = "Lower priority rule to deny all egress traffic."
enable_logging = var.firewall_enable_logging
match = {
@@ -49,7 +49,7 @@ module "firewall_rules" {
priority = "1000"
direction = "EGRESS"
action = "allow"
- rule_name = "fw-${var.environment_code}-shared-restricted-1000-e-a-allow-google-apis-all-tcp-443"
+ rule_name = "fw-${var.environment_code}-svpc-1000-e-a-allow-google-apis-all-tcp-443"
description = "Lower priority rule to allow restricted google apis on TCP port 443."
enable_logging = var.firewall_enable_logging
match = {
@@ -68,7 +68,7 @@ module "firewall_rules" {
priority = "10000"
direction = "EGRESS"
action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-10000-e-a-all-all-all"
+ rule_name = "fw-${var.environment_code}-svpc-10000-e-a-all-all-all"
description = "Allow all egress to the provided IP range."
enable_logging = var.firewall_enable_logging
match = {
@@ -86,7 +86,7 @@ module "firewall_rules" {
priority = "10001"
direction = "INGRESS"
action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-10001-i-a-all"
+ rule_name = "fw-${var.environment_code}-svpc-10001-i-a-all"
description = "Allow all ingress to the provided IP range."
enable_logging = var.firewall_enable_logging
match = {
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/main.tf b/3-networks-hub-and-spoke/modules/shared_vpc/main.tf
similarity index 94%
rename from 3-networks-hub-and-spoke/modules/restricted_shared_vpc/main.tf
rename to 3-networks-hub-and-spoke/modules/shared_vpc/main.tf
index eeafe07bf..243df845a 100644
--- a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/main.tf
+++ b/3-networks-hub-and-spoke/modules/shared_vpc/main.tf
@@ -16,7 +16,7 @@
locals {
mode = var.mode == null ? "" : var.mode == "hub" ? "-hub" : "-spoke"
- vpc_name = "${var.environment_code}-shared-restricted${local.mode}"
+ vpc_name = "${var.environment_code}-svpc${local.mode}"
network_name = "vpc-${local.vpc_name}"
restricted_googleapis_cidr = module.private_service_connect.private_service_connect_ip
google_forward_source_range = "35.199.192.0/19"
@@ -69,11 +69,11 @@ module "main" {
/***************************************************************
VPC Peering Configuration
**************************************************************/
-data "google_compute_network" "vpc_restricted_net_hub" {
+data "google_compute_network" "vpc_net_hub" {
count = var.mode == "spoke" ? 1 : 0
- name = "vpc-c-shared-restricted-hub"
- project = var.restricted_net_hub_project_id
+ name = "vpc-c-svpc-hub"
+ project = var.net_hub_project_id
}
module "peering" {
@@ -83,7 +83,7 @@ module "peering" {
prefix = "np"
local_network = module.main.network_self_link
- peer_network = data.google_compute_network.vpc_restricted_net_hub[0].self_link
+ peer_network = data.google_compute_network.vpc_net_hub[0].self_link
export_peer_custom_routes = true
}
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/nat.tf b/3-networks-hub-and-spoke/modules/shared_vpc/nat.tf
similarity index 100%
rename from 3-networks-hub-and-spoke/modules/restricted_shared_vpc/nat.tf
rename to 3-networks-hub-and-spoke/modules/shared_vpc/nat.tf
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/outputs.tf b/3-networks-hub-and-spoke/modules/shared_vpc/outputs.tf
similarity index 99%
rename from 3-networks-hub-and-spoke/modules/restricted_shared_vpc/outputs.tf
rename to 3-networks-hub-and-spoke/modules/shared_vpc/outputs.tf
index 442fc44dc..617c987fd 100644
--- a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/outputs.tf
+++ b/3-networks-hub-and-spoke/modules/shared_vpc/outputs.tf
@@ -19,7 +19,7 @@ output "network_name" {
description = "The name of the VPC being created"
}
-output "restricted_dns_policy" {
+output "dns_policy" {
value = google_dns_policy.default_policy.name
description = "The name of the DNS policy being created"
}
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/private_service_connect.tf b/3-networks-hub-and-spoke/modules/shared_vpc/private_service_connect.tf
similarity index 92%
rename from 3-networks-hub-and-spoke/modules/restricted_shared_vpc/private_service_connect.tf
rename to 3-networks-hub-and-spoke/modules/shared_vpc/private_service_connect.tf
index 99a49440c..409912772 100644
--- a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/private_service_connect.tf
+++ b/3-networks-hub-and-spoke/modules/shared_vpc/private_service_connect.tf
@@ -20,7 +20,7 @@ module "private_service_connect" {
version = "~> 10.0"
project_id = var.project_id
- dns_code = "dz-${var.environment_code}-shared-restricted"
+ dns_code = "dz-${var.environment_code}-svpc"
network_self_link = module.main.network_self_link
private_service_connect_ip = var.private_service_connect_ip
forwarding_rule_target = "vpc-sc"
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/service_control.tf b/3-networks-hub-and-spoke/modules/shared_vpc/service_control.tf
similarity index 97%
rename from 3-networks-hub-and-spoke/modules/restricted_shared_vpc/service_control.tf
rename to 3-networks-hub-and-spoke/modules/shared_vpc/service_control.tf
index 4772a396c..42921e0f5 100644
--- a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/service_control.tf
+++ b/3-networks-hub-and-spoke/modules/shared_vpc/service_control.tf
@@ -15,7 +15,7 @@
*/
locals {
- prefix = "${var.environment_code}_shared_restricted"
+ prefix = "${var.environment_code}_shared_vpc"
access_level_name = "alp_${local.prefix}_members_${random_id.random_access_level_suffix.hex}"
access_level_name_dry_run = "alp_${local.prefix}_members_dry_run_${random_id.random_access_level_suffix.hex}"
perimeter_name = "sp_${local.prefix}_default_perimeter_${random_id.random_access_level_suffix.hex}"
@@ -112,7 +112,7 @@ resource "google_access_context_manager_service_perimeter" "bridge_to_network_hu
use_explicit_dry_run_spec = var.enforce_vpcsc ? false : true
status {
- resources = var.enforce_vpcsc ? formatlist("projects/%s", [var.project_number, var.restricted_net_hub_project_number]) : []
+ resources = var.enforce_vpcsc ? formatlist("projects/%s", [var.project_number, var.net_hub_project_number]) : []
}
depends_on = [module.regular_service_perimeter]
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/variables.tf b/3-networks-hub-and-spoke/modules/shared_vpc/variables.tf
similarity index 96%
rename from 3-networks-hub-and-spoke/modules/restricted_shared_vpc/variables.tf
rename to 3-networks-hub-and-spoke/modules/shared_vpc/variables.tf
index 4814ff734..b61d41451 100644
--- a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/variables.tf
+++ b/3-networks-hub-and-spoke/modules/shared_vpc/variables.tf
@@ -26,23 +26,23 @@ variable "access_context_manager_policy_id" {
variable "project_id" {
type = string
- description = "Project ID for Restricted Shared VPC."
+ description = "Project ID for Shared VPC."
}
variable "project_number" {
type = number
- description = "Project number for Restricted Shared VPC. It is the project INSIDE the regular service perimeter."
+ description = "Project number for Shared VPC."
}
-variable "restricted_net_hub_project_id" {
+variable "net_hub_project_id" {
type = string
- description = "The restricted net hub project ID"
+ description = "The net hub project ID"
default = ""
}
-variable "restricted_net_hub_project_number" {
+variable "net_hub_project_number" {
type = string
- description = "The restricted net hub project number"
+ description = "The net hub project number"
default = ""
}
diff --git a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/versions.tf b/3-networks-hub-and-spoke/modules/shared_vpc/versions.tf
similarity index 89%
rename from 3-networks-hub-and-spoke/modules/restricted_shared_vpc/versions.tf
rename to 3-networks-hub-and-spoke/modules/shared_vpc/versions.tf
index 4277a2715..2193f4688 100644
--- a/3-networks-hub-and-spoke/modules/restricted_shared_vpc/versions.tf
+++ b/3-networks-hub-and-spoke/modules/shared_vpc/versions.tf
@@ -19,11 +19,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
google-beta = {
source = "hashicorp/google-beta"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
random = {
source = "hashicorp/random"
@@ -31,10 +31,10 @@ terraform {
}
provider_meta "google" {
- module_name = "blueprints/terraform/terraform-example-foundation:restricted_shared_vpc/v4.1.0"
+ module_name = "blueprints/terraform/terraform-example-foundation:shared_vpc/v4.1.0"
}
provider_meta "google-beta" {
- module_name = "blueprints/terraform/terraform-example-foundation:restricted_shared_vpc/v4.1.0"
+ module_name = "blueprints/terraform/terraform-example-foundation:shared_vpc/v4.1.0"
}
}
diff --git a/3-networks-hub-and-spoke/modules/transitivity/versions.tf b/3-networks-hub-and-spoke/modules/transitivity/versions.tf
index 5f77b730f..d70c918f4 100644
--- a/3-networks-hub-and-spoke/modules/transitivity/versions.tf
+++ b/3-networks-hub-and-spoke/modules/transitivity/versions.tf
@@ -18,12 +18,14 @@ terraform {
required_version = ">= 0.13"
required_providers {
google = {
+ // version 6.26.0 removed because of the bug https://github.com/hashicorp/terraform-provider-google/issues/21950
source = "hashicorp/google"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
google-beta = {
+ // version 6.26.0 removed because of the bug https://github.com/hashicorp/terraform-provider-google/issues/21950
source = "hashicorp/google-beta"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
}
diff --git a/3-networks-dual-svpc/.gitignore b/3-networks-svpc/.gitignore
similarity index 100%
rename from 3-networks-dual-svpc/.gitignore
rename to 3-networks-svpc/.gitignore
diff --git a/3-networks-dual-svpc/README.md b/3-networks-svpc/README.md
similarity index 91%
rename from 3-networks-dual-svpc/README.md
rename to 3-networks-svpc/README.md
index f545f1c4e..b8e3a29f2 100644
--- a/3-networks-dual-svpc/README.md
+++ b/3-networks-svpc/README.md
@@ -1,4 +1,4 @@
-# 3-networks-dual-svpc
+# 3-networks-svpc
This repo is part of a multi-part guide that shows how to configure and deploy
the example.com reference architecture described in
@@ -25,16 +25,16 @@ organizational policy.
Google Cloud organization that you've created.
object({
aggregation_interval = optional(string, "INTERVAL_5_SEC")
flow_sampling = optional(string, "0.5")
metadata = optional(string, "INCLUDE_ALL_METADATA")
metadata_fields = optional(list(string), [])
filter_expr = optional(string, "true")
}) | `{}` | no |
| custom\_restricted\_services | List of custom services to be protected by the enforced VPC-SC perimeter. If empty, all supported services (https://cloud.google.com/vpc-service-controls/docs/supported-products) will be protected. | `list(string)` | `[]` | no |
| custom\_restricted\_services\_dry\_run | List of custom services to be protected by the dry-run VPC-SC perimeter. If empty, all supported services (https://cloud.google.com/vpc-service-controls/docs/supported-products) will be protected. | `list(string)` | `[]` | no |
| default\_region1 | First subnet region. The shared vpc modules only configures two regions. | `string` | n/a | yes |
@@ -25,15 +19,15 @@
| ingress\_policies\_dry\_run | A list of all [ingress policies](https://cloud.google.com/vpc-service-controls/docs/ingress-egress-rules#ingress-rules-reference) to use in a dry-run perimeter. Each list object has a `from` and `to` value that describes ingress\_from and ingress\_to.list(object({
from = any
to = any
})) | `[]` | no |
| perimeter\_additional\_members | The list of additional members to be added to the enforced perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the restricted perimeter, add your user in this list. Entries must be in the standard GCP form: `user:email@example.com` or `serviceAccount:my-service-account@example.com`. | `list(string)` | `[]` | no |
| perimeter\_additional\_members\_dry\_run | The list of additional members to be added to the dry-run perimeter access level members list. To be able to see the resources protected by the VPC Service Controls in the restricted perimeter, add your user in this list. Entries must be in the standard GCP form: `user:email@example.com` or `serviceAccount:my-service-account@example.com`. | `list(string)` | `[]` | no |
+| private\_service\_cidr | CIDR range for private service networking. Used for Cloud SQL and other managed services in the Shared Vpc. | `string` | n/a | yes |
+| private\_service\_connect\_ip | The base subnet internal IP to be used as the private service connect endpoint in the Shared VPC | `string` | n/a | yes |
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes |
-| restricted\_private\_service\_cidr | CIDR range for private service networking. Used for Cloud SQL and other managed services in the Restricted Shared Vpc. | `string` | n/a | yes |
-| restricted\_private\_service\_connect\_ip | The base subnet internal IP to be used as the private service connect endpoint in the Restricted Shared VPC | `string` | n/a | yes |
-| restricted\_subnet\_primary\_ranges | The base subnet primary IPTs ranges to the Restricted Shared Vpc. | `map(string)` | n/a | yes |
-| restricted\_subnet\_proxy\_ranges | The base proxy-only subnet primary IPTs ranges to the Restricted Shared Vpc. | `map(string)` | n/a | yes |
-| restricted\_subnet\_secondary\_ranges | The base subnet secondary IPTs ranges to the Restricted Shared Vpc | `map(list(map(string)))` | n/a | yes |
-| restricted\_vpc\_flow\_logs | aggregation\_interval: Toggles the aggregation interval for collecting flow logs. Increasing the interval time will reduce the amount of generated flow logs for long lasting connections. Possible values are: INTERVAL\_5\_SEC, INTERVAL\_30\_SEC, INTERVAL\_1\_MIN, INTERVAL\_5\_MIN, INTERVAL\_10\_MIN, INTERVAL\_15\_MIN.object({
aggregation_interval = optional(string, "INTERVAL_5_SEC")
flow_sampling = optional(string, "0.5")
metadata = optional(string, "INCLUDE_ALL_METADATA")
metadata_fields = optional(list(string), [])
filter_expr = optional(string, "true")
}) | `{}` | no |
+| subnet\_primary\_ranges | The base subnet primary IPTs ranges to the Shared Vpc. | `map(string)` | n/a | yes |
+| subnet\_proxy\_ranges | The base proxy-only subnet primary IPTs ranges to the Shared Vpc. | `map(string)` | n/a | yes |
+| subnet\_secondary\_ranges | The base subnet secondary IPTs ranges to the Shared Vpc | `map(list(map(string)))` | n/a | yes |
| target\_name\_server\_addresses | List of IPv4 address of target name servers for the forwarding zone configuration. See https://cloud.google.com/dns/docs/overview#dns-forwarding-zones for details on target name servers in the context of Cloud DNS forwarding zones. | `list(map(any))` | `[]` | no |
| tfc\_org\_name | Name of the TFC organization | `string` | n/a | yes |
+| vpc\_flow\_logs | aggregation\_interval: Toggles the aggregation interval for collecting flow logs. Increasing the interval time will reduce the amount of generated flow logs for long lasting connections. Possible values are: INTERVAL\_5\_SEC, INTERVAL\_30\_SEC, INTERVAL\_1\_MIN, INTERVAL\_5\_MIN, INTERVAL\_10\_MIN, INTERVAL\_15\_MIN.object({
aggregation_interval = optional(string, "INTERVAL_5_SEC")
flow_sampling = optional(string, "0.5")
metadata = optional(string, "INCLUDE_ALL_METADATA")
metadata_fields = optional(list(string), [])
filter_expr = optional(string, "true")
}) | `{}` | no |
## Outputs
@@ -41,24 +35,15 @@
|------|-------------|
| access\_level\_name | Access context manager access level name for the enforced perimeter |
| access\_level\_name\_dry\_run | Access context manager access level name for the dry-run perimeter |
-| base\_dns\_project\_id | The base DNS project ID |
-| base\_host\_project\_id | The base host project ID |
-| base\_network\_name | The name of the VPC being created |
-| base\_network\_self\_link | The URI of the VPC being created |
-| base\_subnets\_ips | The IPs and CIDRs of the subnets being created |
-| base\_subnets\_names | The names of the subnets being created |
-| base\_subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
-| base\_subnets\_self\_links | The self-links of subnets being created |
| enforce\_vpcsc | Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases. |
-| restricted\_dns\_project\_id | The restricted DNS project ID |
-| restricted\_host\_project\_id | The restricted host project ID |
-| restricted\_network\_name | The name of the VPC being created |
-| restricted\_network\_self\_link | The URI of the VPC being created |
-| restricted\_service\_perimeter\_name | Access context manager service perimeter name for the enforced perimeter |
-| restricted\_subnets\_ips | The IPs and CIDRs of the subnets being created |
-| restricted\_subnets\_names | The names of the subnets being created |
-| restricted\_subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
-| restricted\_subnets\_self\_links | The self-links of subnets being created |
+| network\_name | The name of the VPC being created |
+| network\_self\_link | The URI of the VPC being created |
+| service\_perimeter\_name | Access context manager service perimeter name for the enforced perimeter |
+| shared\_vpc\_host\_project\_id | The shared vpc host project ID |
+| subnets\_ips | The IPs and CIDRs of the subnets being created |
+| subnets\_names | The names of the subnets being created |
+| subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
+| subnets\_self\_links | The self-links of subnets being created |
| target\_name\_server\_addresses | List of IPv4 addresses of the target name servers for the forwarding zone configuration. These IP addresses should point to the name server responsible for replying to DNS queries. |
diff --git a/3-networks-dual-svpc/modules/base_env/interconnect.tf.example b/3-networks-svpc/modules/base_env/interconnect.tf.example
similarity index 63%
rename from 3-networks-dual-svpc/modules/base_env/interconnect.tf.example
rename to 3-networks-svpc/modules/base_env/interconnect.tf.example
index 9246da10c..0c9ad2686 100644
--- a/3-networks-dual-svpc/modules/base_env/interconnect.tf.example
+++ b/3-networks-svpc/modules/base_env/interconnect.tf.example
@@ -83,20 +83,20 @@ locals {
}
}
-module "shared_restricted_interconnect" {
+module "interconnect" {
source = "../dedicated_interconnect"
- vpc_name = "${var.environment_code}-shared-restricted"
- interconnect_project_id = local.restricted_project_id
+ vpc_name = "${var.environment_code}-svpc"
+ interconnect_project_id = local.shared_vpc_project_id
region1 = var.default_region1
- region1_router1_name = module.restricted_shared_vpc.region1_router1.router.name
+ region1_router1_name = module.shared_vpc.region1_router1.router.name
region1_interconnect1_candidate_subnets = local.restricted_config[var.env]["region1_interconnect1_candidate_subnets"]
region1_interconnect1_vlan_tag8021q = local.restricted_config[var.env]["region1_interconnect1_vlan_tag8021q"]
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.restricted_shared_vpc.region1_router2.router.name
+ region1_router2_name = module.shared_vpc.region1_router2.router.name
region1_interconnect2_candidate_subnets = local.restricted_config[var.env]["region1_interconnect2_candidate_subnets"]
region1_interconnect2_vlan_tag8021q = local.restricted_config[var.env]["region1_interconnect2_vlan_tag8021q"]
region1_interconnect2 = "https://www.googleapis.com/compute/v1/projects/${local.interconnect_project_id}/global/interconnects/example-interconnect-2"
@@ -104,13 +104,13 @@ module "shared_restricted_interconnect" {
region1_interconnect2_onprem_dc = "onprem-dc2"
region2 = var.default_region2
- region2_router1_name = module.restricted_shared_vpc.region2_router1.router.name
+ region2_router1_name = module.shared_vpc.region2_router1.router.name
region2_interconnect1_candidate_subnets = local.restricted_config[var.env]["region2_interconnect1_candidate_subnets"]
region2_interconnect1_vlan_tag8021q = local.restricted_config[var.env]["region2_interconnect1_vlan_tag8021q"]
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.restricted_shared_vpc.region2_router2.router.name
+ region2_router2_name = module.shared_vpc.region2_router2.router.name
region2_interconnect2_candidate_subnets = local.restricted_config[var.env]["region2_interconnect2_candidate_subnets"]
region2_interconnect2_vlan_tag8021q = local.restricted_config[var.env]["region2_interconnect2_vlan_tag8021q"]
region2_interconnect2 = "https://www.googleapis.com/compute/v1/projects/${local.interconnect_project_id}/global/interconnects/example-interconnect-4"
@@ -128,56 +128,6 @@ module "shared_restricted_interconnect" {
}
depends_on = [
- module.restricted_shared_vpc
- ]
-}
-
-module "shared_base_interconnect" {
- source = "../dedicated_interconnect"
-
- vpc_name = "${var.environment_code}-shared-base"
- interconnect_project_id = local.base_project_id
-
- region1 = var.default_region1
- region1_router1_name = module.base_shared_vpc.region1_router1.router.name
- region1_interconnect1_candidate_subnets = local.base_config[var.env]["region1_interconnect1_candidate_subnets"]
- region1_interconnect1_vlan_tag8021q = local.base_config[var.env]["region1_interconnect1_vlan_tag8021q"]
- 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.base_shared_vpc.region1_router2.router.name
- region1_interconnect2_candidate_subnets = local.base_config[var.env]["region1_interconnect2_candidate_subnets"]
- region1_interconnect2_vlan_tag8021q = local.base_config[var.env]["region1_interconnect2_vlan_tag8021q"]
- 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 = var.default_region2
- region2_router1_name = module.base_shared_vpc.region2_router1.router.name
- region2_interconnect1_candidate_subnets = local.base_config[var.env]["region2_interconnect1_candidate_subnets"]
- region2_interconnect1_vlan_tag8021q = local.base_config[var.env]["region2_interconnect1_vlan_tag8021q"]
- 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.base_shared_vpc.region2_router2.router.name
- region2_interconnect2_candidate_subnets = local.base_config[var.env]["region2_interconnect2_candidate_subnets"]
- region2_interconnect2_vlan_tag8021q = local.base_config[var.env]["region2_interconnect2_vlan_tag8021q"]
- 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"
- }
-
- depends_on = [
- module.base_shared_vpc
+ module.shared_vpc
]
}
diff --git a/3-networks-dual-svpc/modules/base_env/main.tf b/3-networks-svpc/modules/base_env/main.tf
similarity index 60%
rename from 3-networks-dual-svpc/modules/base_env/main.tf
rename to 3-networks-svpc/modules/base_env/main.tf
index ffd7a9c32..ba632c9db 100644
--- a/3-networks-dual-svpc/modules/base_env/main.tf
+++ b/3-networks-svpc/modules/base_env/main.tf
@@ -164,14 +164,14 @@ locals {
}
/******************************************
- Restricted shared VPC
+ Shared VPC
*****************************************/
-module "restricted_shared_vpc" {
- source = "../restricted_shared_vpc"
+module "shared_vpc" {
+ source = "../shared_vpc"
- project_id = local.restricted_project_id
- project_number = local.restricted_project_number
- restricted_dns_project_id = local.restricted_dns_project_id
+ project_id = local.shared_vpc_project_id
+ project_number = local.shared_vpc_project_number
+ dns_project_id = local.dns_project_id
environment_code = var.environment_code
access_context_manager_policy_id = var.access_context_manager_policy_id
restricted_services = local.restricted_services
@@ -186,8 +186,8 @@ module "restricted_shared_vpc" {
"serviceAccount:${local.projects_service_account}",
"serviceAccount:${local.organization_service_account}",
], var.perimeter_additional_members))
- private_service_cidr = var.restricted_private_service_cidr
- private_service_connect_ip = var.restricted_private_service_connect_ip
+ private_service_cidr = var.private_service_cidr
+ private_service_connect_ip = var.private_service_connect_ip
bgp_asn_subnet = local.bgp_asn_number
default_region1 = var.default_region1
default_region2 = var.default_region2
@@ -208,34 +208,34 @@ module "restricted_shared_vpc" {
subnets = [
{
- subnet_name = "sb-${var.environment_code}-shared-restricted-${var.default_region1}"
- subnet_ip = var.restricted_subnet_primary_ranges[var.default_region1]
+ subnet_name = "sb-${var.environment_code}-svpc-${var.default_region1}"
+ subnet_ip = var.subnet_primary_ranges[var.default_region1]
subnet_region = var.default_region1
subnet_private_access = "true"
subnet_flow_logs = true
- subnet_flow_logs_interval = var.restricted_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.restricted_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.restricted_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.restricted_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.restricted_vpc_flow_logs.filter_expr
+ subnet_flow_logs_interval = var.vpc_flow_logs.aggregation_interval
+ subnet_flow_logs_sampling = var.vpc_flow_logs.flow_sampling
+ subnet_flow_logs_metadata = var.vpc_flow_logs.metadata
+ subnet_flow_logs_metadata_fields = var.vpc_flow_logs.metadata_fields
+ subnet_flow_logs_filter = var.vpc_flow_logs.filter_expr
description = "First ${var.env} subnet example."
},
{
- subnet_name = "sb-${var.environment_code}-shared-restricted-${var.default_region2}"
- subnet_ip = var.restricted_subnet_primary_ranges[var.default_region2]
+ subnet_name = "sb-${var.environment_code}-svpc-${var.default_region2}"
+ subnet_ip = var.subnet_primary_ranges[var.default_region2]
subnet_region = var.default_region2
subnet_private_access = "true"
subnet_flow_logs = true
- subnet_flow_logs_interval = var.restricted_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.restricted_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.restricted_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.restricted_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.restricted_vpc_flow_logs.filter_expr
+ subnet_flow_logs_interval = var.vpc_flow_logs.aggregation_interval
+ subnet_flow_logs_sampling = var.vpc_flow_logs.flow_sampling
+ subnet_flow_logs_metadata = var.vpc_flow_logs.metadata
+ subnet_flow_logs_metadata_fields = var.vpc_flow_logs.metadata_fields
+ subnet_flow_logs_filter = var.vpc_flow_logs.filter_expr
description = "Second ${var.env} subnet example."
},
{
- subnet_name = "sb-${var.environment_code}-shared-restricted-${var.default_region1}-proxy"
- subnet_ip = var.restricted_subnet_proxy_ranges[var.default_region1]
+ subnet_name = "sb-${var.environment_code}-svpc-${var.default_region1}-proxy"
+ subnet_ip = var.subnet_proxy_ranges[var.default_region1]
subnet_region = var.default_region1
subnet_flow_logs = false
description = "First ${var.env} proxy-only subnet example."
@@ -243,8 +243,8 @@ module "restricted_shared_vpc" {
purpose = "REGIONAL_MANAGED_PROXY"
},
{
- subnet_name = "sb-${var.environment_code}-shared-restricted-${var.default_region2}-proxy"
- subnet_ip = var.restricted_subnet_proxy_ranges[var.default_region2]
+ subnet_name = "sb-${var.environment_code}-svpc-${var.default_region2}-proxy"
+ subnet_ip = var.subnet_proxy_ranges[var.default_region2]
subnet_region = var.default_region2
subnet_flow_logs = false
description = "Second ${var.env} proxy-only subnet example."
@@ -253,77 +253,7 @@ module "restricted_shared_vpc" {
}
]
secondary_ranges = {
- "sb-${var.environment_code}-shared-restricted-${var.default_region1}" = var.restricted_subnet_secondary_ranges[var.default_region1]
- }
-}
-
-/******************************************
- Base shared VPC
-*****************************************/
-
-module "base_shared_vpc" {
- source = "../base_shared_vpc"
-
- project_id = local.base_project_id
- base_dns_project_id = local.base_dns_project_id
- environment_code = var.environment_code
- private_service_cidr = var.base_private_service_cidr
- private_service_connect_ip = var.base_private_service_connect_ip
- default_region1 = var.default_region1
- default_region2 = var.default_region2
- domain = var.domain
- bgp_asn_subnet = local.bgp_asn_number
- target_name_server_addresses = var.target_name_server_addresses
-
- subnets = [
- {
- subnet_name = "sb-${var.environment_code}-shared-base-${var.default_region1}"
- subnet_ip = var.base_subnet_primary_ranges[var.default_region1]
- subnet_region = var.default_region1
- subnet_private_access = "true"
- subnet_flow_logs = true
- subnet_flow_logs_interval = var.base_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.base_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.base_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.base_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.base_vpc_flow_logs.filter_expr
- description = "First ${var.env} subnet example."
- },
- {
- subnet_name = "sb-${var.environment_code}-shared-base-${var.default_region2}"
- subnet_ip = var.base_subnet_primary_ranges[var.default_region2]
- subnet_region = var.default_region2
- subnet_private_access = "true"
- subnet_flow_logs = true
- subnet_flow_logs_interval = var.base_vpc_flow_logs.aggregation_interval
- subnet_flow_logs_sampling = var.base_vpc_flow_logs.flow_sampling
- subnet_flow_logs_metadata = var.base_vpc_flow_logs.metadata
- subnet_flow_logs_metadata_fields = var.base_vpc_flow_logs.metadata_fields
- subnet_flow_logs_filter = var.base_vpc_flow_logs.filter_expr
- description = "Second ${var.env} subnet example."
- },
- {
- subnet_name = "sb-${var.environment_code}-shared-base-${var.default_region1}-proxy"
- subnet_ip = var.base_subnet_proxy_ranges[var.default_region1]
- subnet_region = var.default_region1
- subnet_flow_logs = false
- description = "First ${var.env} proxy-only subnet example."
- role = "ACTIVE"
- purpose = "REGIONAL_MANAGED_PROXY"
- },
- {
- subnet_name = "sb-${var.environment_code}-shared-base-${var.default_region2}-proxy"
- subnet_ip = var.base_subnet_proxy_ranges[var.default_region2]
- subnet_region = var.default_region2
- subnet_flow_logs = false
- description = "Second ${var.env} proxy-only subnet example."
- role = "ACTIVE"
- purpose = "REGIONAL_MANAGED_PROXY"
- }
- ]
-
- secondary_ranges = {
- "sb-${var.environment_code}-shared-base-${var.default_region1}" = var.base_subnet_secondary_ranges[var.default_region1]
+ "sb-${var.environment_code}-svpc-${var.default_region1}" = var.subnet_secondary_ranges[var.default_region1]
}
}
diff --git a/3-networks-svpc/modules/base_env/outputs.tf b/3-networks-svpc/modules/base_env/outputs.tf
new file mode 100644
index 000000000..c55a4771c
--- /dev/null
+++ b/3-networks-svpc/modules/base_env/outputs.tf
@@ -0,0 +1,75 @@
+/**
+ * Copyright 2021 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+output "target_name_server_addresses" {
+ value = var.target_name_server_addresses
+ description = "List of IPv4 addresses of the target name servers for the forwarding zone configuration. These IP addresses should point to the name server responsible for replying to DNS queries."
+}
+
+output "shared_vpc_host_project_id" {
+ value = local.shared_vpc_project_id
+ description = "The shared vpc host project ID"
+}
+
+output "network_name" {
+ value = module.shared_vpc.network_name
+ description = "The name of the VPC being created"
+}
+
+output "network_self_link" {
+ value = module.shared_vpc.network_self_link
+ description = "The URI of the VPC being created"
+}
+
+output "subnets_names" {
+ value = module.shared_vpc.subnets_names
+ description = "The names of the subnets being created"
+}
+
+output "subnets_ips" {
+ value = module.shared_vpc.subnets_ips
+ description = "The IPs and CIDRs of the subnets being created"
+}
+
+output "subnets_self_links" {
+ value = module.shared_vpc.subnets_self_links
+ description = "The self-links of subnets being created"
+}
+
+output "subnets_secondary_ranges" {
+ value = module.shared_vpc.subnets_secondary_ranges
+ description = "The secondary ranges associated with these subnets"
+}
+
+output "access_level_name" {
+ value = module.shared_vpc.access_level_name
+ description = "Access context manager access level name for the enforced perimeter"
+}
+
+output "access_level_name_dry_run" {
+ value = module.shared_vpc.access_level_name_dry_run
+ description = "Access context manager access level name for the dry-run perimeter"
+}
+
+output "enforce_vpcsc" {
+ value = module.shared_vpc.enforce_vpcsc
+ description = "Enable the enforced mode for VPC Service Controls. It is not recommended to enable VPC-SC on the first run deploying your foundation. Review [best practices for enabling VPC Service Controls](https://cloud.google.com/vpc-service-controls/docs/enable), then only enforce the perimeter after you have analyzed the access patterns in your dry-run perimeter and created the necessary exceptions for your use cases."
+}
+
+output "service_perimeter_name" {
+ value = module.shared_vpc.service_perimeter_name
+ description = "Access context manager service perimeter name for the enforced perimeter"
+}
diff --git a/3-networks-svpc/modules/base_env/partner_interconnect.tf.example b/3-networks-svpc/modules/base_env/partner_interconnect.tf.example
new file mode 100644
index 000000000..b8c6a41d5
--- /dev/null
+++ b/3-networks-svpc/modules/base_env/partner_interconnect.tf.example
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2021 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+module "interconnect" {
+ source = "../partner_interconnect"
+
+ attachment_project_id = local.shared_vpc_project_id
+ vpc_name = "${var.environment_code}-svpc"
+ preactivate = true
+
+ region1 = var.default_region1
+ region1_router1_name = module.shared_vpc.region1_router1.router.name
+ region1_interconnect1_location = "las-zone1-770"
+ region1_interconnect1_onprem_dc = "onprem-dc1"
+ region1_router2_name = module.shared_vpc.region1_router2.router.name
+ region1_interconnect2_location = "las-zone1-770"
+ region1_interconnect2_onprem_dc = "onprem-dc2"
+
+ region2 = var.default_region2
+ region2_router1_name = module.shared_vpc.region2_router1.router.name
+ region2_interconnect1_location = "lax-zone2-19"
+ region2_interconnect1_onprem_dc = "onprem-dc3"
+ region2_router2_name = module.shared_vpc.region2_router2.router.name
+ region2_interconnect2_location = "lax-zone1-403"
+ region2_interconnect2_onprem_dc = "onprem-dc4"
+
+ cloud_router_labels = {
+ vlan_1 = "cr5",
+ vlan_2 = "cr6",
+ vlan_3 = "cr7",
+ vlan_4 = "cr8"
+ }
+
+ depends_on = [
+ module.shared_vpc
+ ]
+}
diff --git a/3-networks-dual-svpc/modules/base_env/remote.tf b/3-networks-svpc/modules/base_env/remote.tf
similarity index 67%
rename from 3-networks-dual-svpc/modules/base_env/remote.tf
rename to 3-networks-svpc/modules/base_env/remote.tf
index 8c8f853ec..dc6e8f4f7 100644
--- a/3-networks-dual-svpc/modules/base_env/remote.tf
+++ b/3-networks-svpc/modules/base_env/remote.tf
@@ -15,15 +15,13 @@
*/
locals {
- restricted_project_id = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].restricted_shared_vpc_project_id
- base_project_id = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].base_shared_vpc_project_id
- restricted_project_number = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].restricted_shared_vpc_project_number
+ shared_vpc_project_id = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].shared_vpc_project_id
+ shared_vpc_project_number = data.terraform_remote_state.org.outputs.shared_vpc_projects[var.env].shared_vpc_project_number
interconnect_project_number = data.terraform_remote_state.org.outputs.interconnect_project_number
organization_service_account = data.terraform_remote_state.bootstrap.outputs.organization_step_terraform_service_account_email
networks_service_account = data.terraform_remote_state.bootstrap.outputs.networks_step_terraform_service_account_email
projects_service_account = data.terraform_remote_state.bootstrap.outputs.projects_step_terraform_service_account_email
- restricted_dns_project_id = data.terraform_remote_state.org.outputs.shared_vpc_projects["production"].restricted_shared_vpc_project_id
- base_dns_project_id = data.terraform_remote_state.org.outputs.shared_vpc_projects["production"].base_shared_vpc_project_id
+ dns_project_id = data.terraform_remote_state.org.outputs.shared_vpc_projects["production"].shared_vpc_project_id
}
data "terraform_remote_state" "bootstrap" {
diff --git a/3-networks-dual-svpc/modules/base_env/remote.tf.cloud.example b/3-networks-svpc/modules/base_env/remote.tf.cloud.example
similarity index 75%
rename from 3-networks-dual-svpc/modules/base_env/remote.tf.cloud.example
rename to 3-networks-svpc/modules/base_env/remote.tf.cloud.example
index df60f9e1c..3bbd96d42 100644
--- a/3-networks-dual-svpc/modules/base_env/remote.tf.cloud.example
+++ b/3-networks-svpc/modules/base_env/remote.tf.cloud.example
@@ -15,9 +15,8 @@
*/
locals {
- restricted_project_id = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].restricted_shared_vpc_project_id
- restricted_project_number = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].restricted_shared_vpc_project_number
- base_project_id = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].base_shared_vpc_project_id
+ shared_vpc_project_id = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].shared_vpc_project_id
+ shared_vpc_project_number = data.tfe_outputs.org.nonsensitive_values.shared_vpc_projects[var.env].shared_vpc_project_number
interconnect_project_number = data.tfe_outputs.org.nonsensitive_values.interconnect_project_number
organization_service_account = data.tfe_outputs.bootstrap.nonsensitive_values.organization_step_terraform_service_account_email
networks_service_account = data.tfe_outputs.bootstrap.nonsensitive_values.networks_step_terraform_service_account_email
diff --git a/3-networks-dual-svpc/modules/base_env/variables.tf b/3-networks-svpc/modules/base_env/variables.tf
similarity index 77%
rename from 3-networks-dual-svpc/modules/base_env/variables.tf
rename to 3-networks-svpc/modules/base_env/variables.tf
index 4bb88ca6c..378bf1788 100644
--- a/3-networks-dual-svpc/modules/base_env/variables.tf
+++ b/3-networks-svpc/modules/base_env/variables.tf
@@ -67,75 +67,32 @@ variable "enable_partner_interconnect" {
default = false
}
-variable "base_private_service_cidr" {
+variable "private_service_cidr" {
type = string
- description = "CIDR range for private service networking. Used for Cloud SQL and other managed services in the Base Shared Vpc."
+ description = "CIDR range for private service networking. Used for Cloud SQL and other managed services in the Shared Vpc."
}
-variable "base_subnet_primary_ranges" {
+variable "subnet_primary_ranges" {
type = map(string)
- description = "The base subnet primary IPTs ranges to the Base Shared Vpc."
+ description = "The base subnet primary IPTs ranges to the Shared Vpc."
}
-variable "base_subnet_proxy_ranges" {
+variable "subnet_proxy_ranges" {
type = map(string)
- description = "The base proxy-only subnet primary IPTs ranges to the Base Shared Vpc."
+ description = "The base proxy-only subnet primary IPTs ranges to the Shared Vpc."
}
-variable "base_subnet_secondary_ranges" {
+variable "subnet_secondary_ranges" {
type = map(list(map(string)))
- description = "The base subnet secondary IPTs ranges to the Base Shared Vpc."
+ description = "The base subnet secondary IPTs ranges to the Shared Vpc"
}
-variable "base_private_service_connect_ip" {
+variable "private_service_connect_ip" {
type = string
- description = "The base subnet internal IP to be used as the private service connect endpoint in the Base Shared VPC"
+ description = "The base subnet internal IP to be used as the private service connect endpoint in the Shared VPC"
}
-variable "base_vpc_flow_logs" {
- description = <list(object({
from = any
to = any
})) | `[]` | no |
| egress\_policies\_dry\_run | A list of all [egress policies](https://cloud.google.com/vpc-service-controls/docs/ingress-egress-rules#egress-rules-reference) to use in a dry-run perimeter. Each list object has a `from` and `to` value that describes egress\_from and egress\_to.list(object({
from = any
to = any
})) | `[]` | no |
@@ -26,9 +27,8 @@
| nat\_num\_addresses\_region2 | Number of external IPs to reserve for region 2 Cloud NAT. | `number` | `2` | no |
| private\_service\_cidr | CIDR range for private service networking. Used for Cloud SQL and other managed services. | `string` | `null` | no |
| private\_service\_connect\_ip | Internal IP to be used as the private service connect endpoint. | `string` | n/a | yes |
-| project\_id | Project ID for Restricted Shared VPC. | `string` | n/a | yes |
-| project\_number | Project number for Restricted Shared VPC. It is the project INSIDE the regular service perimeter. | `number` | n/a | yes |
-| restricted\_dns\_project\_id | Project ID for DNS Restricted Shared. | `string` | `""` | no |
+| project\_id | Project ID for Shared VPC. | `string` | n/a | yes |
+| project\_number | Project number for Shared VPC. | `number` | n/a | yes |
| restricted\_services | List of services to restrict in an enforced perimeter. | `list(string)` | n/a | yes |
| restricted\_services\_dry\_run | List of services to restrict in a dry-run perimeter. | `list(string)` | n/a | yes |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no |
diff --git a/3-networks-dual-svpc/modules/base_shared_vpc/dns.tf b/3-networks-svpc/modules/shared_vpc/dns.tf
similarity index 90%
rename from 3-networks-dual-svpc/modules/base_shared_vpc/dns.tf
rename to 3-networks-svpc/modules/shared_vpc/dns.tf
index dd065135e..d6a38a6fd 100644
--- a/3-networks-dual-svpc/modules/base_shared_vpc/dns.tf
+++ b/3-networks-svpc/modules/shared_vpc/dns.tf
@@ -20,7 +20,7 @@
resource "google_dns_policy" "default_policy" {
project = var.project_id
- name = "dp-${var.environment_code}-shared-base-default-policy"
+ name = "dp-${var.environment_code}-svpc-default-policy"
enable_inbound_forwarding = var.dns_enable_inbound_forwarding
enable_logging = var.dns_enable_logging
networks {
@@ -35,8 +35,8 @@ data "google_compute_network" "vpc_dns_hub" {
count = var.environment_code != "p" ? 1 : 0
- name = "vpc-p-shared-base"
- project = var.base_dns_project_id
+ name = "vpc-p-svpc"
+ project = var.dns_project_id
}
module "peering_zone" {
@@ -47,7 +47,7 @@ module "peering_zone" {
project_id = var.project_id
type = "peering"
- name = "dz-${var.environment_code}-shared-base-to-dns-hub"
+ name = "dz-${var.environment_code}-svpc-to-dns-hub"
domain = var.domain
description = "Private DNS peering zone."
@@ -76,3 +76,4 @@ module "dns_forwarding_zone" {
]
target_name_server_addresses = var.target_name_server_addresses
}
+
diff --git a/3-networks-dual-svpc/modules/restricted_shared_vpc/firewall.tf b/3-networks-svpc/modules/shared_vpc/firewall.tf
similarity index 84%
rename from 3-networks-dual-svpc/modules/restricted_shared_vpc/firewall.tf
rename to 3-networks-svpc/modules/shared_vpc/firewall.tf
index 3e35b3d7c..41ed2eb67 100644
--- a/3-networks-dual-svpc/modules/restricted_shared_vpc/firewall.tf
+++ b/3-networks-svpc/modules/shared_vpc/firewall.tf
@@ -23,8 +23,8 @@ module "firewall_rules" {
version = "~> 10.0"
project_id = var.project_id
- policy_name = "fp-${var.environment_code}-dual-svpc-restricted-firewalls"
- description = "Firewall rules for restricted dual shared vpc: ${module.main.network_name}."
+ policy_name = "fp-${var.environment_code}-svpc-firewalls"
+ description = "Firewall rules for shared vpc: ${module.main.network_name}."
target_vpcs = ["projects/${var.project_id}/global/networks/${module.main.network_name}"]
rules = concat(
@@ -33,7 +33,7 @@ module "firewall_rules" {
priority = "65530"
direction = "EGRESS"
action = "deny"
- rule_name = "fw-${var.environment_code}-shared-restricted-65530-e-d-all-all-all"
+ rule_name = "fw-${var.environment_code}-svpc-65530-e-d-all-all-all"
description = "Lower priority rule to deny all egress traffic."
enable_logging = var.firewall_enable_logging
match = {
@@ -49,7 +49,7 @@ module "firewall_rules" {
priority = "1000"
direction = "EGRESS"
action = "allow"
- rule_name = "fw-${var.environment_code}-shared-restricted-1000-e-a-allow-google-apis-all-tcp-443"
+ rule_name = "fw-${var.environment_code}-svpc-1000-e-a-allow-google-apis-all-tcp-443"
description = "Lower priority rule to allow restricted google apis on TCP port 443."
enable_logging = var.firewall_enable_logging
match = {
@@ -68,7 +68,7 @@ module "firewall_rules" {
priority = "10000"
direction = "EGRESS"
action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-10000-e-a-all-all-all"
+ rule_name = "fw-${var.environment_code}-svpc-10000-e-a-all-all-all"
description = "Allow all egress to the provided IP range."
enable_logging = var.firewall_enable_logging
match = {
@@ -86,7 +86,7 @@ module "firewall_rules" {
priority = "10001"
direction = "INGRESS"
action = "allow"
- rule_name = "fw-${var.environment_code}-shared-base-10001-i-a-all"
+ rule_name = "fw-${var.environment_code}-svpc-10001-i-a-all"
description = "Allow all ingress to the provided IP range."
enable_logging = var.firewall_enable_logging
match = {
diff --git a/3-networks-dual-svpc/modules/restricted_shared_vpc/main.tf b/3-networks-svpc/modules/shared_vpc/main.tf
similarity index 98%
rename from 3-networks-dual-svpc/modules/restricted_shared_vpc/main.tf
rename to 3-networks-svpc/modules/shared_vpc/main.tf
index 75792e367..4d117a85d 100644
--- a/3-networks-dual-svpc/modules/restricted_shared_vpc/main.tf
+++ b/3-networks-svpc/modules/shared_vpc/main.tf
@@ -15,7 +15,7 @@
*/
locals {
- vpc_name = "${var.environment_code}-shared-restricted"
+ vpc_name = "${var.environment_code}-svpc"
network_name = "vpc-${local.vpc_name}"
restricted_googleapis_cidr = module.private_service_connect.private_service_connect_ip
google_forward_source_range = "35.199.192.0/19"
diff --git a/3-networks-dual-svpc/modules/restricted_shared_vpc/nat.tf b/3-networks-svpc/modules/shared_vpc/nat.tf
similarity index 100%
rename from 3-networks-dual-svpc/modules/restricted_shared_vpc/nat.tf
rename to 3-networks-svpc/modules/shared_vpc/nat.tf
diff --git a/3-networks-dual-svpc/modules/restricted_shared_vpc/outputs.tf b/3-networks-svpc/modules/shared_vpc/outputs.tf
similarity index 100%
rename from 3-networks-dual-svpc/modules/restricted_shared_vpc/outputs.tf
rename to 3-networks-svpc/modules/shared_vpc/outputs.tf
diff --git a/3-networks-dual-svpc/modules/restricted_shared_vpc/private_service_connect.tf b/3-networks-svpc/modules/shared_vpc/private_service_connect.tf
similarity index 92%
rename from 3-networks-dual-svpc/modules/restricted_shared_vpc/private_service_connect.tf
rename to 3-networks-svpc/modules/shared_vpc/private_service_connect.tf
index 3294a0ce5..50b6cb88e 100644
--- a/3-networks-dual-svpc/modules/restricted_shared_vpc/private_service_connect.tf
+++ b/3-networks-svpc/modules/shared_vpc/private_service_connect.tf
@@ -20,7 +20,7 @@ module "private_service_connect" {
version = "~> 10.0"
project_id = var.project_id
- dns_code = "dz-${var.environment_code}-shared-restricted"
+ dns_code = "dz-${var.environment_code}-svpc"
network_self_link = module.main.network_self_link
private_service_connect_ip = var.private_service_connect_ip
forwarding_rule_target = "vpc-sc"
diff --git a/3-networks-dual-svpc/modules/restricted_shared_vpc/service_control.tf b/3-networks-svpc/modules/shared_vpc/service_control.tf
similarity index 98%
rename from 3-networks-dual-svpc/modules/restricted_shared_vpc/service_control.tf
rename to 3-networks-svpc/modules/shared_vpc/service_control.tf
index 636dcb2bf..16c8905fd 100644
--- a/3-networks-dual-svpc/modules/restricted_shared_vpc/service_control.tf
+++ b/3-networks-svpc/modules/shared_vpc/service_control.tf
@@ -15,7 +15,7 @@
*/
locals {
- prefix = "${var.environment_code}_shared_restricted"
+ prefix = "${var.environment_code}_svpc"
access_level_name = "alp_${local.prefix}_members_${random_id.random_access_level_suffix.hex}"
access_level_name_dry_run = "alp_${local.prefix}_members_dry_run_${random_id.random_access_level_suffix.hex}"
perimeter_name = "sp_${local.prefix}_default_perimeter_${random_id.random_access_level_suffix.hex}"
diff --git a/3-networks-dual-svpc/modules/restricted_shared_vpc/variables.tf b/3-networks-svpc/modules/shared_vpc/variables.tf
similarity index 98%
rename from 3-networks-dual-svpc/modules/restricted_shared_vpc/variables.tf
rename to 3-networks-svpc/modules/shared_vpc/variables.tf
index 27e733385..6342467f2 100644
--- a/3-networks-dual-svpc/modules/restricted_shared_vpc/variables.tf
+++ b/3-networks-svpc/modules/shared_vpc/variables.tf
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-variable "restricted_dns_project_id" {
+variable "dns_project_id" {
description = "Project ID for DNS Restricted Shared."
type = string
default = ""
@@ -32,12 +32,12 @@ variable "access_context_manager_policy_id" {
variable "project_id" {
type = string
- description = "Project ID for Restricted Shared VPC."
+ description = "Project ID for Shared VPC."
}
variable "project_number" {
type = number
- description = "Project number for Restricted Shared VPC. It is the project INSIDE the regular service perimeter."
+ description = "Project number for Shared VPC."
}
variable "environment_code" {
diff --git a/3-networks-dual-svpc/modules/restricted_shared_vpc/versions.tf b/3-networks-svpc/modules/shared_vpc/versions.tf
similarity index 93%
rename from 3-networks-dual-svpc/modules/restricted_shared_vpc/versions.tf
rename to 3-networks-svpc/modules/shared_vpc/versions.tf
index 234c7d5c7..70d2dd824 100644
--- a/3-networks-dual-svpc/modules/restricted_shared_vpc/versions.tf
+++ b/3-networks-svpc/modules/shared_vpc/versions.tf
@@ -19,11 +19,11 @@ terraform {
required_providers {
google = {
source = "hashicorp/google"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
google-beta = {
source = "hashicorp/google-beta"
- version = ">= 3.50"
+ version = ">= 3.50, < 6.26.0"
}
random = {
source = "hashicorp/random"
diff --git a/3-networks-dual-svpc/modules/vpn-ha/README.md b/3-networks-svpc/modules/vpn-ha/README.md
similarity index 98%
rename from 3-networks-dual-svpc/modules/vpn-ha/README.md
rename to 3-networks-svpc/modules/vpn-ha/README.md
index 4e85d3059..1c58b85bf 100755
--- a/3-networks-dual-svpc/modules/vpn-ha/README.md
+++ b/3-networks-svpc/modules/vpn-ha/README.md
@@ -7,7 +7,7 @@ If you are not able to use Dedicated Interconnect or Partner Interconnect you ca
## Usage
-1. Rename `vpn.tf.example` to `vpn.tf` in the environment folder in `3-networks-dual-svpc/envs/