Align resource names in FAST networking stages (#2115)

* stage c nva

* fix tests

* remove moved blocks from net c stage

* simplify subnet naming in stage 2 net e

* address most renames in stage 2 e

* address most renames in stage 2 e

* address most renames in stage 2 e

* complete renames in stage 2 e

* use non-regional names in subnets

* use non-regional names in subnets

* use non-regional names in subnets
This commit is contained in:
Ludovico Magnocavallo 2024-02-29 07:45:19 +01:00 committed by GitHub
parent ae6ee03de2
commit 3972eb6df4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
85 changed files with 4097 additions and 525 deletions

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-dataplatform
region: europe-west1
description: Default subnet for dev Data Platform
ip_cidr_range: 10.68.2.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-default
region: europe-west1
ip_cidr_range: 10.68.0.0/24
description: Default subnet for dev

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-gke-nodes
region: europe-west1
description: Default subnet for prod gke nodes
ip_cidr_range: 10.68.1.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: landing-default
region: europe-west1
ip_cidr_range: 10.64.0.0/24
description: Default subnet for landing

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: prod-default
region: europe-west1
ip_cidr_range: 10.72.0.0/24
description: Default subnet for prod

View File

@ -18,11 +18,6 @@
# GCP-specific environment zone
moved {
from = module.dev-dns-private-zone
to = module.dev-dns-priv-example
}
module "dev-dns-priv-example" {
source = "../../../modules/dns"
project_id = module.dev-spoke-project.project_id
@ -40,11 +35,6 @@ module "dev-dns-priv-example" {
# root zone peering to landing to centralize configuration; remove if unneeded
moved {
from = module.dev-landing-root-dns-peering
to = module.dev-dns-peer-landing-root
}
module "dev-dns-peer-landing-root" {
source = "../../../modules/dns"
project_id = module.dev-spoke-project.project_id
@ -58,11 +48,6 @@ module "dev-dns-peer-landing-root" {
}
}
moved {
from = module.dev-reverse-10-dns-peering
to = module.dev-dns-peer-landing-rev-10
}
module "dev-dns-peer-landing-rev-10" {
source = "../../../modules/dns"
project_id = module.dev-spoke-project.project_id

View File

@ -18,11 +18,6 @@
# forwarding to on-prem DNS resolvers
moved {
from = module.onprem-example-dns-forwarding
to = module.landing-dns-fwd-onprem-example
}
module "landing-dns-fwd-onprem-example" {
source = "../../../modules/dns"
count = length(var.dns.resolvers) > 0 ? 1 : 0
@ -37,11 +32,6 @@ module "landing-dns-fwd-onprem-example" {
}
}
moved {
from = module.reverse-10-dns-forwarding
to = module.landing-dns-fwd-onprem-rev-10
}
module "landing-dns-fwd-onprem-rev-10" {
source = "../../../modules/dns"
count = length(var.dns.resolvers) > 0 ? 1 : 0
@ -56,11 +46,6 @@ module "landing-dns-fwd-onprem-rev-10" {
}
}
moved {
from = module.gcp-example-dns-private-zone
to = module.landing-dns-priv-gcp
}
module "landing-dns-priv-gcp" {
source = "../../../modules/dns"
project_id = module.landing-project.project_id

View File

@ -18,11 +18,6 @@
# GCP-specific environment zone
moved {
from = module.prod-dns-private-zone
to = module.prod-dns-priv-example
}
module "prod-dns-priv-example" {
source = "../../../modules/dns"
project_id = module.prod-spoke-project.project_id
@ -40,11 +35,6 @@ module "prod-dns-priv-example" {
# root zone peering to landing to centralize configuration; remove if unneeded
moved {
from = module.prod-landing-root-dns-peering
to = module.prod-dns-peer-landing-root
}
module "prod-dns-peer-landing-root" {
source = "../../../modules/dns"
project_id = module.prod-spoke-project.project_id
@ -58,11 +48,6 @@ module "prod-dns-peer-landing-root" {
}
}
moved {
from = module.prod-reverse-10-dns-peering
to = module.prod-dns-peer-landing-rev-10
}
module "prod-dns-peer-landing-rev-10" {
source = "../../../modules/dns"
project_id = module.prod-spoke-project.project_id

View File

@ -74,11 +74,6 @@ module "landing-firewall" {
}
}
moved {
from = module.landing-nat-ew1
to = module.landing-nat-primary
}
module "landing-nat-primary" {
source = "../../../modules/net-cloudnat"
count = var.enable_cloud_nat ? 1 : 0

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-dataplatform
region: europe-west1
description: Default subnet for dev Data Platform
ip_cidr_range: 10.68.2.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-default
region: europe-west1
ip_cidr_range: 10.68.0.0/24
description: Default subnet for dev

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-gke-nodes
region: europe-west1
description: Default subnet for prod gke nodes
ip_cidr_range: 10.68.1.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: landing-default
region: europe-west1
ip_cidr_range: 10.64.0.0/24
description: Default subnet for landing

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: prod-default
region: europe-west1
ip_cidr_range: 10.72.0.0/24
description: Default subnet for prod

View File

@ -18,11 +18,6 @@
# GCP-specific environment zone
moved {
from = module.dev-dns-private-zone
to = module.dev-dns-priv-example
}
module "dev-dns-priv-example" {
source = "../../../modules/dns"
project_id = module.dev-spoke-project.project_id
@ -40,11 +35,6 @@ module "dev-dns-priv-example" {
# root zone peering to landing to centralize configuration; remove if unneeded
moved {
from = module.dev-landing-root-dns-peering
to = module.dev-dns-peer-landing-root
}
module "dev-dns-peer-landing-root" {
source = "../../../modules/dns"
project_id = module.dev-spoke-project.project_id
@ -58,11 +48,6 @@ module "dev-dns-peer-landing-root" {
}
}
moved {
from = module.dev-reverse-10-dns-peering
to = module.dev-dns-peer-landing-rev-10
}
module "dev-dns-peer-landing-rev-10" {
source = "../../../modules/dns"
project_id = module.dev-spoke-project.project_id

View File

@ -18,11 +18,6 @@
# forwarding to on-prem DNS resolvers
moved {
from = module.onprem-example-dns-forwarding
to = module.landing-dns-fwd-onprem-example
}
module "landing-dns-fwd-onprem-example" {
source = "../../../modules/dns"
count = length(var.dns.resolvers) > 0 ? 1 : 0
@ -37,11 +32,6 @@ module "landing-dns-fwd-onprem-example" {
}
}
moved {
from = module.reverse-10-dns-forwarding
to = module.landing-dns-fwd-onprem-rev-10
}
module "landing-dns-fwd-onprem-rev-10" {
source = "../../../modules/dns"
count = length(var.dns.resolvers) > 0 ? 1 : 0
@ -56,11 +46,6 @@ module "landing-dns-fwd-onprem-rev-10" {
}
}
moved {
from = module.gcp-example-dns-private-zone
to = module.landing-dns-priv-gcp
}
module "landing-dns-priv-gcp" {
source = "../../../modules/dns"
project_id = module.landing-project.project_id

View File

@ -18,11 +18,6 @@
# GCP-specific environment zone
moved {
from = module.prod-dns-private-zone
to = module.prod-dns-priv-example
}
module "prod-dns-priv-example" {
source = "../../../modules/dns"
project_id = module.prod-spoke-project.project_id
@ -40,11 +35,6 @@ module "prod-dns-priv-example" {
# root zone peering to landing to centralize configuration; remove if unneeded
moved {
from = module.prod-landing-root-dns-peering
to = module.prod-dns-peer-landing-root
}
module "prod-dns-peer-landing-root" {
source = "../../../modules/dns"
project_id = module.prod-spoke-project.project_id
@ -58,11 +48,6 @@ module "prod-dns-peer-landing-root" {
}
}
moved {
from = module.prod-reverse-10-dns-peering
to = module.prod-dns-peer-landing-rev-10
}
module "prod-dns-peer-landing-rev-10" {
source = "../../../modules/dns"
project_id = module.prod-spoke-project.project_id

View File

@ -74,11 +74,6 @@ module "landing-firewall" {
}
}
moved {
from = module.landing-nat-ew1
to = module.landing-nat-primary
}
module "landing-nat-primary" {
source = "../../../modules/net-cloudnat"
count = var.enable_cloud_nat ? 1 : 0

View File

@ -2,11 +2,11 @@
This stage sets up the shared network infrastructure for the whole organization.
It is designed for those who would like to leverage Network Virtual Appliances (NVAs) between trusted and untrusted areas of the network, for example for Intrusion Prevention System (IPS) purposes.
It is designed for those who would like to leverage Network Virtual Appliances (NVAs) between landing and dmz areas of the network, for example for Intrusion Prevention System (IPS) purposes.
It adopts the common “hub and spoke” reference design, which is well suited for multiple scenarios, and it offers several advantages versus other designs:
- the "trusted hub" VPC centralizes the external connectivity towards trusted network resources (e.g. on-prem, other cloud environments and the spokes), and it is ready to host cross-environment services like CI/CD, code repositories, and monitoring probes
- the "landing hub" VPC centralizes the external connectivity towards landing network resources (e.g. on-prem, other cloud environments and the spokes), and it is ready to host cross-environment services like CI/CD, code repositories, and monitoring probes
- the "spoke" VPCs allow partitioning workloads (e.g. by environment like in this setup), while still retaining controlled access to central connectivity and services
- Shared VPCs -both in hub and spokes- split the management of the network resources into specific (host) projects, while still allowing them to be consumed from the workload (service) projects
- the design facilitates DNS centralization
@ -70,20 +70,20 @@ This provides enough redundancy to be resilient to regional failures.
The "landing zone" is divided into two VPC networks:
- the trusted VPC: the connectivity hub towards other trusted networks
- the untrusted VPC: the connectivity hub towards any other untrusted network
- the landing VPC: the connectivity hub towards other landing networks
- the dmz VPC: the connectivity hub towards any other dmz network
The VPCs are connected with two sets of sample NVA machines, grouped in regional (multi-zone) [Managed Instance Groups (MIGs)](https://cloud.google.com/compute/docs/instance-groups). The appliances are plain Linux machines, performing simple routing/natting, leveraging some standard Linux features, such as *ip route* or *iptables*. The appliances are suited for demo purposes only and they should be replaced with enterprise-grade solutions before moving to production.
The traffic destined to the VMs in each MIG is mediated through regional internal load balancers, both in the trusted and in the untrusted networks.
The traffic destined to the VMs in each MIG is mediated through regional internal load balancers, both in the landing and in the dmz networks.
By default, the design assumes the following:
- on-premise networks (and related resources) are considered trusted. As such, the VPNs connecting with on-premises are terminated in GCP, in the trusted VPC
- the public Internet is considered untrusted. As such [Cloud NAT](https://cloud.google.com/nat/docs/overview) is deployed in the untrusted landing VPC only
- cross-environment traffic and traffic from any untrusted network to any trusted network (and vice versa) pass through the NVAs. For demo purposes, the current NVA performs simple routing/natting only
- any traffic from a trusted network to an untrusted network (e.g. Internet) is natted by the NVAs. Users can configure further exclusions
- on-premise networks (and related resources) are considered landing. As such, the VPNs connecting with on-premises are terminated in GCP, in the landing VPC
- the public Internet is considered dmz. As such [Cloud NAT](https://cloud.google.com/nat/docs/overview) is deployed in the dmz landing VPC only
- cross-environment traffic and traffic from any dmz network to any landing network (and vice versa) pass through the NVAs. For demo purposes, the current NVA performs simple routing/natting only
- any traffic from a landing network to an dmz network (e.g. Internet) is natted by the NVAs. Users can configure further exclusions
The trusted landing VPC acts as a hub: it bridges internal resources with the outside world and it hosts the shared services consumed by the spoke VPCs, connected to the hub through VPC network peerings. Spokes are used to partition the environments. By default:
The landing landing VPC acts as a hub: it bridges internal resources with the outside world and it hosts the shared services consumed by the spoke VPCs, connected to the hub through VPC network peerings. Spokes are used to partition the environments. By default:
- one spoke VPC hosts the development environment resources
- one spoke VPC hosts the production environment resources
@ -99,18 +99,18 @@ In multi-organization scenarios, where production and non-production resources u
External connectivity to on-prem is implemented leveraging [Cloud HA VPN](https://cloud.google.com/network-connectivity/docs/vpn/concepts/topologies) (two tunnels per region). This is what users normally deploy as a final solution, or to validate routing and to transfer data, while waiting for [interconnects](https://cloud.google.com/network-connectivity/docs/interconnect) to be provisioned.
Connectivity to additional on-prem sites or to other cloud providers should be implemented in a similar fashion, via VPN tunnels or interconnects, in the landing VPC (either trusted or untrusted, depending by the nature of the peers), sharing the same regional routers.
Connectivity to additional on-prem sites or to other cloud providers should be implemented in a similar fashion, via VPN tunnels or interconnects, in the landing VPC (either landing or dmz, depending by the nature of the peers), sharing the same regional routers.
### Internal connectivity
Internal connectivity (e.g. between the trusted landing VPC and the spokes) is realized with VPC network peerings. As mentioned, there are other ways to implement connectivity. These can be easily retrofitted with minimal code changes, although they introduce additional considerations on service interoperability, quotas and management.
Internal connectivity (e.g. between the landing landing VPC and the spokes) is realized with VPC network peerings. As mentioned, there are other ways to implement connectivity. These can be easily retrofitted with minimal code changes, although they introduce additional considerations on service interoperability, quotas and management.
This is an options summary:
- [VPC Peering](https://cloud.google.com/vpc/docs/vpc-peering) (used here to connect the trusted landing VPC with the spokes, also used by [02-networking-vpn](../2-networking-b-vpn/))
- [VPC Peering](https://cloud.google.com/vpc/docs/vpc-peering) (used here to connect the landing landing VPC with the spokes, also used by [02-networking-vpn](../2-networking-b-vpn/))
- Pros: no additional costs, full bandwidth with no configurations, no extra latency
- Cons: no transitivity (e.g. to GKE masters, Cloud SQL, etc.), no selective exchange of routes, several quotas and limits shared between VPCs in a peering group
- [Multi-NIC appliances](https://cloud.google.com/architecture/best-practices-vpc-design#multi-nic) (used here to connect the trusted landing and untrusted VPCs) and multi-NIC appliances with NCC/BGP support implemented [here](../2-networking-e-nva-bgp/)
- [Multi-NIC appliances](https://cloud.google.com/architecture/best-practices-vpc-design#multi-nic) (used here to connect the landing landing and dmz VPCs) and multi-NIC appliances with NCC/BGP support implemented [here](../2-networking-e-nva-bgp/)
- Pros: provides additional security features (e.g. IPS), potentially better integration with on-prem systems by using the same vendor
- Cons: complex HA/failover setup, limited by VM bandwidth and scale, additional costs for VMs and licenses, out of band management of a critical cloud component
- [HA VPN](https://cloud.google.com/network-connectivity/docs/vpn/concepts/topologies)
@ -123,7 +123,7 @@ Minimizing the number of routes (and subnets) in the cloud environment is import
This stage uses a dedicated /11 block (10.64.0.0/11), which should be sized to the own needs. The subnets created in each VPC derive from this range.
The /11 block is evenly split in eight, smaller /16 blocks, assigned to different areas of the GCP network: *landing untrusted europe-west1*, *landing untrusted europe-west4*, *landing trusted europe-west1*, *landing untrusted europe-west4*, *development europe-west1*, *development europe-west4*, *production europe-west1*, *production europe-west4*.
The /11 block is evenly split in eight, smaller /16 blocks, assigned to different areas of the GCP network: *landing dmz europe-west1*, *landing dmz europe-west4*, *landing landing europe-west1*, *landing dmz europe-west4*, *development europe-west1*, *development europe-west4*, *production europe-west1*, *production europe-west4*.
The first /24 range in every area is allocated for a default subnet, which can be removed or modified as needed. The last three /24 ranges can be used for [PSA (Private Service Access)](https://cloud.google.com/vpc/docs/private-services-access)via the `psa_ranges` variable, or for [Internal Application Load Balancers (L7 LBs)](https://cloud.google.com/load-balancing/docs/l7-internal) subnets via the factory.
@ -131,10 +131,10 @@ This is a summary of the subnets allocated by default in this setup:
| name | description | CIDR |
|---|---|---|
| landing-trusted-default-ew1 | Trusted landing subnet - europe-west1 | 10.128.64.0/24 |
| landing-trusted-default-ew4 | Trusted landing subnet - europe-west4 | 10.128.96.0/24 |
| landing-untrusted-default-ew1 | Untrusted landing subnet - europe-west1 | 10.128.0.0/24 |
| landing-untrusted-default-ew4 | Untrusted landing subnet - europe-west4 | 10.128.32.0/24 |
| landing-default-ew1 | landing landing subnet - europe-west1 | 10.128.64.0/24 |
| landing-default-ew4 | landing landing subnet - europe-west4 | 10.128.96.0/24 |
| dmz-default-ew1 | dmz landing subnet - europe-west1 | 10.128.0.0/24 |
| dmz-default-ew4 | dmz landing subnet - europe-west4 | 10.128.32.0/24 |
| dev-default-ew1 | Dev spoke subnet - europe-west1 | 10.68.0.0/24 |
| dev-default-ew1 | Free (PSA) - europe-west1 | 10.68.253.0/24 |
| dev-default-ew1 | Free (PSA) - europe-west1 | 10.68.254.0/24 |
@ -159,17 +159,17 @@ Routes in GCP are either automatically created (for example, when a subnet is ad
In this setup:
- routes between multiple subnets within the same VPC are automatically exchanged by GCP
- the spokes and the trusted landing VPC exchange routes through VPC peerings
- on-premises is connected to the trusted landing VPC and it dynamically exchanges BGP routes with GCP (with the trusted VPC) using HA VPN
- for cross-environment (spokes) communications, and for connections to on-premises and to the Internet, the spokes leverage some default tagged routes that send the traffic of each region (whose machines are identified by a dedicated network tag, e.g. *ew1*) to a corresponding regional NVA in the trusted VPC, through an ILB (whose VIP is set as the route next-hop)
- the spokes and the landing landing VPC exchange routes through VPC peerings
- on-premises is connected to the landing landing VPC and it dynamically exchanges BGP routes with GCP (with the landing VPC) using HA VPN
- for cross-environment (spokes) communications, and for connections to on-premises and to the Internet, the spokes leverage some default tagged routes that send the traffic of each region (whose machines are identified by a dedicated network tag, e.g. *ew1*) to a corresponding regional NVA in the landing VPC, through an ILB (whose VIP is set as the route next-hop)
- the spokes are configured with backup default routes, so if the NVAs in the same region become unavailable, more routes to the NVAs in the other region are already available. Current routes are not able to understand if the next-hop ILBs become unhealthy. As such, in case of a regional failure, users will need to manually withdraw the primary default routes, so the secondaries will take over
- the NVAs are configured with static routes that allow the communication with on-premises and between the GCP resources (including the cross-environment communication)
The Cloud Routers (connected to the VPN gateways in the trusted VPC) are configured to exclude the default advertisement of VPC ranges and they only advertise their respective aggregate ranges, via custom advertisements. This greatly simplifies the routing configuration and avoids quota or limit issues, by keeping the number of routes small, instead of making it proportional to the subnets and to the secondary ranges in the VPCs.
The Cloud Routers (connected to the VPN gateways in the landing VPC) are configured to exclude the default advertisement of VPC ranges and they only advertise their respective aggregate ranges, via custom advertisements. This greatly simplifies the routing configuration and avoids quota or limit issues, by keeping the number of routes small, instead of making it proportional to the subnets and to the secondary ranges in the VPCs.
### Internet egress
In this setup, Internet egress is realized through [Cloud NAT](https://cloud.google.com/nat/docs/overview), deployed in the untrusted landing VPC. This allows instances in all other VPCs to reach the Internet, passing through the NVAs (being the public Internet considered untrusted). Cloud NAT is disabled by default; enable it by setting the `enable_cloud_nat` variable
In this setup, Internet egress is realized through [Cloud NAT](https://cloud.google.com/nat/docs/overview), deployed in the dmz landing VPC. This allows instances in all other VPCs to reach the Internet, passing through the NVAs (being the public Internet considered dmz). Cloud NAT is disabled by default; enable it by setting the `enable_cloud_nat` variable
Several other scenarios are possible, with various degrees of complexity:
@ -214,30 +214,30 @@ This configuration is battle-tested, and flexible enough to lend itself to simpl
### VPCs
VPCs are defined in separate files, one for `landing` (trusted and untrusted), one for `prod` and one for `dev`.
VPCs are defined in separate files, one for `landing` (landing and dmz), one for `prod` and one for `dev`.
These files contain different resources:
- **project** ([`projects`](../../../modules/project)): the "[host projects](https://cloud.google.com/vpc/docs/shared-vpc)" containing the VPCs and enabling the required APIs.
- **VPCs** ([`net-vpc`](../../../modules/net-vpc)): manages the subnets, the explicit routes for `{private,restricted}.googleapis.com` and the DNS inbound policy for the trusted landing VPC. Non-infrastructural subnets are created leveraging resource factories. Sample subnets are shipped in [data/subnets](./data/subnets) and can be easily customized to fit users' needs. [PSA](https://cloud.google.com/vpc/docs/configure-private-services-access#allocating-range) are configured by the variable `psa_ranges` if managed services are needed.
- **Cloud NAT** ([`net-cloudnat`](../../../modules/net-cloudnat)) (in the untrusted landing VPC only): it manages the networking infrastructure required to enable the Internet egress.
- **VPCs** ([`net-vpc`](../../../modules/net-vpc)): manages the subnets, the explicit routes for `{private,restricted}.googleapis.com` and the DNS inbound policy for the landing landing VPC. Non-infrastructural subnets are created leveraging resource factories. Sample subnets are shipped in [data/subnets](./data/subnets) and can be easily customized to fit users' needs. [PSA](https://cloud.google.com/vpc/docs/configure-private-services-access#allocating-range) are configured by the variable `psa_ranges` if managed services are needed.
- **Cloud NAT** ([`net-cloudnat`](../../../modules/net-cloudnat)) (in the dmz landing VPC only): it manages the networking infrastructure required to enable the Internet egress.
### VPNs
The connectivity between on-premises and GCP (the trusted landing VPC) is implemented with Cloud HA VPN ([`net-vpn`](../../../modules/net-vpn-ha)) and defined in [`vpn-onprem.tf`](./vpn-onprem.tf). The file implements a single logical connection between on-premises and the trusted landing VPC, both in `europe-west1` and `europe-west4`. The relevant parameters for its configuration are found in the variables `vpn_onprem_primary_config` and `vpn_onprem_secondary_config`.
The connectivity between on-premises and GCP (the landing landing VPC) is implemented with Cloud HA VPN ([`net-vpn`](../../../modules/net-vpn-ha)) and defined in [`vpn-onprem.tf`](./vpn-onprem.tf). The file implements a single logical connection between on-premises and the landing landing VPC, both in `europe-west1` and `europe-west4`. The relevant parameters for its configuration are found in the variables `vpn_onprem_primary_config` and `vpn_onprem_secondary_config`.
### Routing and BGP
Each VPC network ([`net-vpc`](../../../modules/net-vpc)) manages a separate routing table, which can define static routes (e.g. to private.googleapis.com) and receives dynamic routes through VPC peering and BGP sessions established with the neighbor networks (e.g. the trusted landing VPC receives routes from on-premises, and the spokes receive RFC1918 from the trusted landing VPC).
Each VPC network ([`net-vpc`](../../../modules/net-vpc)) manages a separate routing table, which can define static routes (e.g. to private.googleapis.com) and receives dynamic routes through VPC peering and BGP sessions established with the neighbor networks (e.g. the landing landing VPC receives routes from on-premises, and the spokes receive RFC1918 from the landing landing VPC).
Static routes are defined in `vpc-*.tf` files in the `routes` section of each `net-vpc` module.
BGP sessions for trusted landing to on-premises are configured through the variable `vpn_onprem_configs`.
BGP sessions for landing landing to on-premises are configured through the variable `vpn_onprem_configs`.
### Firewall
**VPC firewall rules** ([`net-vpc-firewall`](../../../modules/net-vpc-firewall)) are defined per-vpc on each `vpc-*.tf` file and leverage a resource factory to massively create rules.
To add a new firewall rule, create a new file or edit an existing one in the `data_folder` directory defined in the module `net-vpc-firewall`, following the examples of the "[Rules factory](../../../modules/net-vpc-firewall#rules-factory)" section of the module documentation. Sample firewall rules are shipped in [data/firewall-rules/landing-untrusted](./data/firewall-rules/landing-untrusted) and in [data/firewall-rules/landing-trusted](./data/firewall-rules/landing-trusted), and can be easily customized.
To add a new firewall rule, create a new file or edit an existing one in the `data_folder` directory defined in the module `net-vpc-firewall`, following the examples of the "[Rules factory](../../../modules/net-vpc-firewall#rules-factory)" section of the module documentation. Sample firewall rules are shipped in [data/firewall-rules/dmz](./data/firewall-rules/dmz) and in [data/firewall-rules/landing](./data/firewall-rules/landing), and can be easily customized.
**Hierarchical firewall policies** ([`folder`](../../../modules/folder)) are defined in `main.tf` and managed through a policy factory implemented by the `net-firewall-policy` module, which is then applied to the `Networking` folder containing all the core networking infrastructure. Policies are defined in the `rules_file` file, to define a new one simply use the [firewall policy module documentation](../../../modules/net-firewall-policy/README.md#factory)". Sample hierarchical firewall rules are shipped in [data/hierarchical-ingress-rules.yaml](./data/hierarchical-ingress-rules.yaml) and can be easily customised.
@ -250,7 +250,7 @@ Cloud DNS manages onprem forwarding, the main GCP zone (in this example `gcp.exa
#### Cloud environment
The root DNS zone defined in the landing project acts as the source of truth for DNS within the Cloud environment. The resources defined in the spoke VPCs consume the landing DNS infrastructure through DNS peering (e.g. `prod-landing-root-dns-peering`).
The spokes can optionally define private zones (e.g. `prod-dns-private-zone`). Granting visibility both to the trusted and untrusted landing VPCs ensures that the whole cloud environment can query such zones.
The spokes can optionally define private zones (e.g. `prod-dns-private-zone`). Granting visibility both to the landing and dmz landing VPCs ensures that the whole cloud environment can query such zones.
#### Cloud to on-prem
@ -260,7 +260,7 @@ DNS queries sent to the on-premise infrastructure come from the `35.199.192.0/19
#### On-prem to cloud
The [Inbound DNS Policy](https://cloud.google.com/dns/docs/server-policies-overview#dns-server-policy-in) defined in the *trusted landing VPC module* ([`net-landing.tf`](./net-landing.tf)) automatically reserves the first available IP address on each subnet (typically the third one in a CIDR) to expose the Cloud DNS service, so that it can be consumed from outside of GCP.
The [Inbound DNS Policy](https://cloud.google.com/dns/docs/server-policies-overview#dns-server-policy-in) defined in the *landing landing VPC module* ([`net-landing.tf`](./net-landing.tf)) automatically reserves the first available IP address on each subnet (typically the third one in a CIDR) to expose the Cloud DNS service, so that it can be consumed from outside of GCP.
## How to run this stage
@ -352,7 +352,7 @@ terraform apply
[Private Google Access](https://cloud.google.com/vpc/docs/private-google-access) (or PGA) enables VMs and on-prem systems to consume Google APIs from within the Google network, and is already fully configured on this environment:
- DNS response policies in the landing project implement rules for all supported domains reachable via PGA
- routes for the private and restricted ranges are defined in all VPCs except untrusted
- routes for the private and restricted ranges are defined in all VPCs except dmz
To enable PGA access from on premises advertise the private/restricted ranges via the `vpn_onprem_primary_config` and `vpn_onprem_secondary_config` variables, using router or tunnel custom advertisements.
@ -467,7 +467,7 @@ DNS configurations are centralised in the `dns-*.tf` files. Spokes delegate DNS
| [enable_cloud_nat](variables.tf#L82) | Deploy Cloud NAT. | <code>bool</code> | | <code>false</code> | |
| [essential_contacts](variables.tf#L89) | Email used for essential contacts, unset if null. | <code>string</code> | | <code>null</code> | |
| [factories_config](variables.tf#L95) | Configuration for network resource factories. | <code title="object&#40;&#123;&#10; data_dir &#61; optional&#40;string, &#34;data&#34;&#41;&#10; dns_policy_rules_file &#61; optional&#40;string, &#34;data&#47;dns-policy-rules.yaml&#34;&#41;&#10; firewall_policy_name &#61; optional&#40;string, &#34;net-default&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; data_dir &#61; &#34;data&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [gcp_ranges](variables.tf#L126) | GCP address ranges in name => range format. | <code>map&#40;string&#41;</code> | | <code title="&#123;&#10; gcp_dev_primary &#61; &#34;10.68.0.0&#47;16&#34;&#10; gcp_dev_secondary &#61; &#34;10.84.0.0&#47;16&#34;&#10; gcp_landing_trusted_primary &#61; &#34;10.64.0.0&#47;17&#34;&#10; gcp_landing_trusted_secondary &#61; &#34;10.80.0.0&#47;17&#34;&#10; gcp_landing_untrusted_primary &#61; &#34;10.64.127.0&#47;17&#34;&#10; gcp_landing_untrusted_secondary &#61; &#34;10.80.127.0&#47;17&#34;&#10; gcp_prod_primary &#61; &#34;10.72.0.0&#47;16&#34;&#10; gcp_prod_secondary &#61; &#34;10.88.0.0&#47;16&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [gcp_ranges](variables.tf#L126) | GCP address ranges in name => range format. | <code>map&#40;string&#41;</code> | | <code title="&#123;&#10; gcp_dev_primary &#61; &#34;10.68.0.0&#47;16&#34;&#10; gcp_dev_secondary &#61; &#34;10.84.0.0&#47;16&#34;&#10; gcp_landing_landing_primary &#61; &#34;10.64.0.0&#47;17&#34;&#10; gcp_landing_landing_secondary &#61; &#34;10.80.0.0&#47;17&#34;&#10; gcp_dmz_primary &#61; &#34;10.64.127.0&#47;17&#34;&#10; gcp_dmz_secondary &#61; &#34;10.80.127.0&#47;17&#34;&#10; gcp_prod_primary &#61; &#34;10.72.0.0&#47;16&#34;&#10; gcp_prod_secondary &#61; &#34;10.88.0.0&#47;16&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [onprem_cidr](variables.tf#L141) | Onprem addresses in name => range format. | <code>map&#40;string&#41;</code> | | <code title="&#123;&#10; main &#61; &#34;10.0.0.0&#47;24&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [outputs_location](variables.tf#L159) | Path where providers and tfvars files for the following stages are written. Leave empty to disable. | <code>string</code> | | <code>null</code> | |
| [psa_ranges](variables.tf#L176) | IP ranges used for Private Service Access (e.g. CloudSQL). Ranges is in name => range format. | <code title="object&#40;&#123;&#10; dev &#61; object&#40;&#123;&#10; ranges &#61; map&#40;string&#41;&#10; export_routes &#61; optional&#40;bool, false&#41;&#10; import_routes &#61; optional&#40;bool, false&#41;&#10; peered_domains &#61; optional&#40;list&#40;string&#41;, &#91;&#93;&#41;&#10; &#125;&#41;&#10; prod &#61; object&#40;&#123;&#10; ranges &#61; map&#40;string&#41;&#10; export_routes &#61; optional&#40;bool, false&#41;&#10; import_routes &#61; optional&#40;bool, false&#41;&#10; peered_domains &#61; optional&#40;list&#40;string&#41;, &#91;&#93;&#41;&#10; &#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> | |

View File

@ -1,7 +1,7 @@
# skip boilerplate check
ingress:
trusted-ingress-default-deny:
dmz-ingress-default-deny:
description: "Deny and log any unmatched ingress traffic."
deny: true
priority: 65535

View File

@ -4,7 +4,7 @@
# You can retain `---` (start of the document) to indicate an empty document.
ingress:
allow-hc-nva-ssh-untrusted:
allow-hc-nva-ssh-dmz:
description: "Allow traffic from Google healthchecks to NVA appliances"
source_ranges:
- healthchecks

View File

@ -1,7 +1,7 @@
# skip boilerplate check
ingress:
trusted-ingress-default-deny:
landing-ingress-default-deny:
description: "Deny and log any unmatched ingress traffic."
deny: true
priority: 65535

View File

@ -4,7 +4,7 @@
# You can retain `---` (start of the document) to indicate an empty document.
ingress:
allow-hc-nva-ssh-trusted:
allow-hc-nva-ssh-landing:
description: "Allow traffic from Google healthchecks to NVA appliances"
source_ranges:
- healthchecks
@ -12,7 +12,7 @@ ingress:
- protocol: tcp
ports:
- 22
allow-onprem-probes-trusted-example:
allow-onprem-probes-landing-example:
description: "Allow traffic from onprem probes"
source_ranges:
- onprem_probes

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-dataplatform
region: europe-west1
description: Default subnet for dev Data Platform
ip_cidr_range: 10.68.2.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-default
region: europe-west1
ip_cidr_range: 10.68.0.0/24
description: Default europe-west1 subnet for dev

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-default
region: europe-west4
ip_cidr_range: 10.84.0.0/24
description: Default europe-west4 subnet for dev

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-gke-nodes
region: europe-west1
description: Default subnet for prod gke nodes
ip_cidr_range: 10.68.1.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dmz
region: europe-west1
ip_cidr_range: 10.64.128.0/24
description: Default europe-west1 subnet for landing untrusted
description: Default europe-west1 subnet for landing dmz

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dmz
region: europe-west4
ip_cidr_range: 10.80.128.0/24
description: Default europe-west4 subnet for landing untrusted
description: Default europe-west4 subnet for landing dmz

View File

@ -1,5 +0,0 @@
# skip boilerplate check
region: europe-west1
ip_cidr_range: 10.64.0.0/24
description: Default europe-west1 subnet for landing trusted

View File

@ -1,5 +0,0 @@
# skip boilerplate check
region: europe-west4
ip_cidr_range: 10.80.0.0/24
description: Default europe-west4 subnet for landing trusted

View File

@ -0,0 +1,6 @@
# skip boilerplate check
name: landing-default
region: europe-west1
ip_cidr_range: 10.64.0.0/24
description: Default europe-west1 subnet for landing landing

View File

@ -0,0 +1,6 @@
# skip boilerplate check
name: landing-default
region: europe-west4
ip_cidr_range: 10.80.0.0/24
description: Default europe-west4 subnet for landing landing

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: prod-default
region: europe-west1
ip_cidr_range: 10.72.0.0/24
description: Default europe-west1 subnet for prod

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: prod-default
region: europe-west4
ip_cidr_range: 10.88.0.0/24
description: Default europe-west4 subnet for prod

View File

@ -18,14 +18,17 @@
# GCP-specific environment zone
module "dev-dns-private-zone" {
module "dev-dns-priv-example" {
source = "../../../modules/dns"
project_id = module.dev-spoke-project.project_id
name = "dev-gcp-example-com"
zone_config = {
domain = "dev.gcp.example.com."
private = {
client_networks = [module.landing-trusted-vpc.self_link, module.landing-untrusted-vpc.self_link]
client_networks = [
module.landing-vpc.self_link,
module.dmz-vpc.self_link
]
}
}
recordsets = {
@ -35,11 +38,6 @@ module "dev-dns-private-zone" {
# root zone peering to landing to centralize configuration; remove if unneeded
moved {
from = module.dev-landing-root-dns-peering
to = module.dev-dns-peer-landing-root
}
module "dev-dns-peer-landing-root" {
source = "../../../modules/dns"
project_id = module.dev-spoke-project.project_id
@ -48,16 +46,11 @@ module "dev-dns-peer-landing-root" {
domain = "."
peering = {
client_networks = [module.dev-spoke-vpc.self_link]
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}
}
}
moved {
from = module.dev-reverse-10-dns-peering
to = module.dev-dns-peer-landing-rev-10
}
module "dev-dns-peer-landing-rev-10" {
source = "../../../modules/dns"
project_id = module.dev-spoke-project.project_id
@ -66,7 +59,7 @@ module "dev-dns-peer-landing-rev-10" {
domain = "10.in-addr.arpa."
peering = {
client_networks = [module.dev-spoke-vpc.self_link]
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}
}
}

View File

@ -18,11 +18,6 @@
# forwarding to on-prem DNS resolvers
moved {
from = module.onprem-example-dns-forwarding
to = module.landing-dns-fwd-onprem-example
}
module "landing-dns-fwd-onprem-example" {
source = "../../../modules/dns"
count = length(var.dns.resolvers) > 0 ? 1 : 0
@ -32,19 +27,14 @@ module "landing-dns-fwd-onprem-example" {
domain = "onprem.example.com."
forwarding = {
client_networks = [
module.landing-untrusted-vpc.self_link,
module.landing-trusted-vpc.self_link
module.dmz-vpc.self_link,
module.landing-vpc.self_link
]
forwarders = { for ip in var.dns.resolvers : ip => null }
}
}
}
moved {
from = module.reverse-10-dns-forwarding
to = module.landing-dns-fwd-onprem-rev-10
}
module "landing-dns-fwd-onprem-rev-10" {
source = "../../../modules/dns"
count = length(var.dns.resolvers) > 0 ? 1 : 0
@ -54,19 +44,14 @@ module "landing-dns-fwd-onprem-rev-10" {
domain = "10.in-addr.arpa."
forwarding = {
client_networks = [
module.landing-untrusted-vpc.self_link,
module.landing-trusted-vpc.self_link
module.dmz-vpc.self_link,
module.landing-vpc.self_link
]
forwarders = { for ip in var.dns.resolvers : ip => null }
}
}
}
moved {
from = module.gcp-example-dns-private-zone
to = module.landing-dns-priv-gcp
}
module "landing-dns-priv-gcp" {
source = "../../../modules/dns"
project_id = module.landing-project.project_id
@ -75,8 +60,8 @@ module "landing-dns-priv-gcp" {
domain = "gcp.example.com."
private = {
client_networks = [
module.landing-untrusted-vpc.self_link,
module.landing-trusted-vpc.self_link
module.dmz-vpc.self_link,
module.landing-vpc.self_link
]
}
}
@ -85,7 +70,7 @@ module "landing-dns-priv-gcp" {
}
}
# Google APIs
# Google APIs via response policies
module "landing-dns-policy-googleapis" {
source = "../../../modules/dns-response-policy"
@ -95,7 +80,7 @@ module "landing-dns-policy-googleapis" {
rules = var.factories_config.dns_policy_rules_file
}
networks = {
landing-trusted = module.landing-trusted-vpc.self_link
landing-untrusted = module.landing-untrusted-vpc.self_link
landing = module.landing-vpc.self_link
dmz = module.dmz-vpc.self_link
}
}

View File

@ -18,14 +18,14 @@
# GCP-specific environment zone
module "prod-dns-private-zone" {
module "prod-dns-priv-example" {
source = "../../../modules/dns"
project_id = module.prod-spoke-project.project_id
name = "prod-gcp-example-com"
zone_config = {
domain = "prod.gcp.example.com."
private = {
client_networks = [module.landing-trusted-vpc.self_link, module.landing-untrusted-vpc.self_link]
client_networks = [module.landing-vpc.self_link, module.dmz-vpc.self_link]
}
}
recordsets = {
@ -35,11 +35,6 @@ module "prod-dns-private-zone" {
# root zone peering to landing to centralize configuration; remove if unneeded
moved {
from = module.prod-landing-root-dns-peering
to = module.prod-dns-peer-landing-root
}
module "prod-dns-peer-landing-root" {
source = "../../../modules/dns"
project_id = module.prod-spoke-project.project_id
@ -48,16 +43,11 @@ module "prod-dns-peer-landing-root" {
domain = "."
peering = {
client_networks = [module.prod-spoke-vpc.self_link]
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}
}
}
moved {
from = module.prod-reverse-10-dns-peering
to = module.prod-dns-peer-landing-rev-10
}
module "prod-dns-peer-landing-rev-10" {
source = "../../../modules/dns"
project_id = module.prod-spoke-project.project_id
@ -66,7 +56,7 @@ module "prod-dns-peer-landing-rev-10" {
domain = "10.in-addr.arpa."
peering = {
client_networks = [module.prod-spoke-vpc.self_link]
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}
}
}

View File

@ -22,8 +22,8 @@ locals {
regions = distinct(concat(
values(var.regions),
values(module.dev-spoke-vpc.subnet_regions),
values(module.landing-trusted-vpc.subnet_regions),
values(module.landing-untrusted-vpc.subnet_regions),
values(module.landing-vpc.subnet_regions),
values(module.dmz-vpc.subnet_regions),
values(module.prod-spoke-vpc.subnet_regions),
))
service_accounts = {

View File

@ -23,6 +23,7 @@ module "dev-spoke-project" {
parent = var.folder_ids.networking-dev
prefix = var.prefix
services = [
"container.googleapis.com",
"compute.googleapis.com",
"dns.googleapis.com",
"iap.googleapis.com",
@ -88,28 +89,28 @@ module "dev-spoke-vpc" {
priority = 1000
tags = ["primary"]
next_hop_type = "ilb"
next_hop = module.ilb-nva-trusted["primary"].forwarding_rule_addresses[""]
next_hop = module.ilb-nva-landing["primary"].forwarding_rule_addresses[""]
}
nva-secondary-to-secondary = {
dest_range = "0.0.0.0/0"
priority = 1000
tags = ["secondary"]
next_hop_type = "ilb"
next_hop = module.ilb-nva-trusted["secondary"].forwarding_rule_addresses[""]
next_hop = module.ilb-nva-landing["secondary"].forwarding_rule_addresses[""]
}
nva-primary-to-secondary = {
dest_range = "0.0.0.0/0"
priority = 1001
tags = ["primary"]
next_hop_type = "ilb"
next_hop = module.ilb-nva-trusted["primary"].forwarding_rule_addresses[""]
next_hop = module.ilb-nva-landing["primary"].forwarding_rule_addresses[""]
}
nva-secondary-to-primary = {
dest_range = "0.0.0.0/0"
priority = 1001
tags = ["secondary"]
next_hop_type = "ilb"
next_hop = module.ilb-nva-trusted["secondary"].forwarding_rule_addresses[""]
next_hop = module.ilb-nva-landing["secondary"].forwarding_rule_addresses[""]
}
}
}
@ -131,5 +132,5 @@ module "peering-dev" {
source = "../../../modules/net-vpc-peering"
prefix = "dev-peering-0"
local_network = module.dev-spoke-vpc.self_link
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}

View File

@ -42,12 +42,12 @@ module "landing-project" {
}
}
# Untrusted VPC
# DMZ (untrusted) VPC
module "landing-untrusted-vpc" {
module "dmz-vpc" {
source = "../../../modules/net-vpc"
project_id = module.landing-project.project_id
name = "prod-untrusted-landing-0"
name = "prod-dmz-0"
mtu = 1500
dns_policy = {
inbound = true
@ -55,31 +55,26 @@ module "landing-untrusted-vpc" {
}
create_googleapis_routes = null
factories_config = {
subnets_folder = "${var.factories_config.data_dir}/subnets/landing-untrusted"
subnets_folder = "${var.factories_config.data_dir}/subnets/dmz"
}
}
module "landing-untrusted-firewall" {
module "dmz-firewall" {
source = "../../../modules/net-vpc-firewall"
project_id = module.landing-project.project_id
network = module.landing-untrusted-vpc.name
network = module.dmz-vpc.name
default_rules_config = {
disabled = true
}
factories_config = {
cidr_tpl_file = "${var.factories_config.data_dir}/cidrs.yaml"
rules_folder = "${var.factories_config.data_dir}/firewall-rules/landing-untrusted"
rules_folder = "${var.factories_config.data_dir}/firewall-rules/dmz"
}
}
# NAT
moved {
from = module.landing-nat-ew1
to = module.landing-nat-primary
}
module "landing-nat-primary" {
module "dmz-nat-primary" {
source = "../../../modules/net-cloudnat"
count = var.enable_cloud_nat ? 1 : 0
project_id = module.landing-project.project_id
@ -87,15 +82,10 @@ module "landing-nat-primary" {
name = local.region_shortnames[var.regions.primary]
router_create = true
router_name = "prod-nat-${local.region_shortnames[var.regions.primary]}"
router_network = module.landing-untrusted-vpc.name
router_network = module.dmz-vpc.name
}
moved {
from = module.landing-nat-ew4
to = module.landing-nat-secondary
}
module "landing-nat-secondary" {
module "dmz-nat-secondary" {
source = "../../../modules/net-cloudnat"
count = var.enable_cloud_nat ? 1 : 0
project_id = module.landing-project.project_id
@ -103,19 +93,19 @@ module "landing-nat-secondary" {
name = local.region_shortnames[var.regions.secondary]
router_create = true
router_name = "prod-nat-${local.region_shortnames[var.regions.secondary]}"
router_network = module.landing-untrusted-vpc.name
router_network = module.dmz-vpc.name
}
# Trusted VPC
# Landing (trusted) VPC
module "landing-trusted-vpc" {
module "landing-vpc" {
source = "../../../modules/net-vpc"
project_id = module.landing-project.project_id
name = "prod-trusted-landing-0"
name = "prod-landing-0"
delete_default_routes_on_create = true
mtu = 1500
factories_config = {
subnets_folder = "${var.factories_config.data_dir}/subnets/landing-trusted"
subnets_folder = "${var.factories_config.data_dir}/subnets/landing"
}
dns_policy = {
inbound = true
@ -127,15 +117,15 @@ module "landing-trusted-vpc" {
}
}
module "landing-trusted-firewall" {
module "landing-firewall" {
source = "../../../modules/net-vpc-firewall"
project_id = module.landing-project.project_id
network = module.landing-trusted-vpc.name
network = module.landing-vpc.name
default_rules_config = {
disabled = true
}
factories_config = {
cidr_tpl_file = "${var.factories_config.data_dir}/cidrs.yaml"
rules_folder = "${var.factories_config.data_dir}/firewall-rules/landing-trusted"
rules_folder = "${var.factories_config.data_dir}/firewall-rules/landing"
}
}

View File

@ -23,6 +23,7 @@ module "prod-spoke-project" {
parent = var.folder_ids.networking-prod
prefix = var.prefix
services = [
"container.googleapis.com",
"compute.googleapis.com",
"dns.googleapis.com",
"iap.googleapis.com",
@ -86,28 +87,28 @@ module "prod-spoke-vpc" {
priority = 1000
tags = ["primary"]
next_hop_type = "ilb"
next_hop = module.ilb-nva-trusted["primary"].forwarding_rule_addresses[""]
next_hop = module.ilb-nva-landing["primary"].forwarding_rule_addresses[""]
}
nva-secondary-to-secondary = {
dest_range = "0.0.0.0/0"
priority = 1000
tags = ["secondary"]
next_hop_type = "ilb"
next_hop = module.ilb-nva-trusted["secondary"].forwarding_rule_addresses[""]
next_hop = module.ilb-nva-landing["secondary"].forwarding_rule_addresses[""]
}
nva-primary-to-secondary = {
dest_range = "0.0.0.0/0"
priority = 1001
tags = ["primary"]
next_hop_type = "ilb"
next_hop = module.ilb-nva-trusted["secondary"].forwarding_rule_addresses[""]
next_hop = module.ilb-nva-landing["secondary"].forwarding_rule_addresses[""]
}
nva-secondary-to-primary = {
dest_range = "0.0.0.0/0"
priority = 1001
tags = ["secondary"]
next_hop_type = "ilb"
next_hop = module.ilb-nva-trusted["primary"].forwarding_rule_addresses[""]
next_hop = module.ilb-nva-landing["primary"].forwarding_rule_addresses[""]
}
}
}
@ -129,5 +130,5 @@ module "peering-prod" {
source = "../../../modules/net-vpc-peering"
prefix = "prod-peering-0"
local_network = module.prod-spoke-vpc.self_link
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}

View File

@ -19,20 +19,20 @@ locals {
# local.routing_config[0] sets up the first interface, and so on.
routing_config = [
{
name = "untrusted"
name = "dmz"
enable_masquerading = true
routes = [
var.gcp_ranges.gcp_landing_untrusted_primary,
var.gcp_ranges.gcp_landing_untrusted_secondary,
var.gcp_ranges.gcp_dmz_primary,
var.gcp_ranges.gcp_dmz_secondary,
]
},
{
name = "trusted"
name = "landing"
routes = [
var.gcp_ranges.gcp_dev_primary,
var.gcp_ranges.gcp_dev_secondary,
var.gcp_ranges.gcp_landing_trusted_primary,
var.gcp_ranges.gcp_landing_trusted_secondary,
var.gcp_ranges.gcp_landing_landing_primary,
var.gcp_ranges.gcp_landing_landing_secondary,
var.gcp_ranges.gcp_prod_primary,
var.gcp_ranges.gcp_prod_secondary,
]
@ -69,16 +69,20 @@ module "nva-template" {
can_ip_forward = true
network_interfaces = [
{
network = module.landing-untrusted-vpc.self_link
subnetwork = module.landing-untrusted-vpc.subnet_self_links["${each.value.region}/landing-untrusted-default-${each.value.shortname}"]
nat = false
addresses = null
network = module.dmz-vpc.self_link
subnetwork = try(
module.dmz-vpc.subnet_self_links["${each.value.region}/dmz-default"], null
)
nat = false
addresses = null
},
{
network = module.landing-trusted-vpc.self_link
subnetwork = module.landing-trusted-vpc.subnet_self_links["${each.value.region}/landing-trusted-default-${each.value.shortname}"]
nat = false
addresses = null
network = module.landing-vpc.self_link
subnetwork = try(
module.landing-vpc.subnet_self_links["${each.value.region}/landing-default"], null
)
nat = false
addresses = null
}
]
boot_disk = {
@ -116,18 +120,18 @@ module "nva-mig" {
}
}
module "ilb-nva-untrusted" {
module "ilb-nva-dmz" {
for_each = {
for k, v in var.regions : k => {
region = v
shortname = local.region_shortnames[v]
subnet = "${v}/landing-untrusted-default-${local.region_shortnames[v]}"
subnet = "${v}/dmz-default-${local.region_shortnames[v]}"
}
}
source = "../../../modules/net-lb-int"
project_id = module.landing-project.project_id
region = each.value.region
name = "nva-untrusted-${each.key}"
name = "nva-dmz-${each.key}"
service_label = var.prefix
forwarding_rules_config = {
"" = {
@ -135,8 +139,8 @@ module "ilb-nva-untrusted" {
}
}
vpc_config = {
network = module.landing-untrusted-vpc.self_link
subnetwork = module.landing-untrusted-vpc.subnet_self_links[each.value.subnet]
network = module.dmz-vpc.self_link
subnetwork = try(module.dmz-vpc.subnet_self_links[each.value.subnet], null)
}
backends = [
for k, v in module.nva-mig :
@ -151,18 +155,18 @@ module "ilb-nva-untrusted" {
}
}
module "ilb-nva-trusted" {
module "ilb-nva-landing" {
for_each = {
for k, v in var.regions : k => {
region = v
shortname = local.region_shortnames[v]
subnet = "${v}/landing-trusted-default-${local.region_shortnames[v]}"
subnet = "${v}/landing-default-${local.region_shortnames[v]}"
}
}
source = "../../../modules/net-lb-int"
project_id = module.landing-project.project_id
region = each.value.region
name = "nva-trusted-${each.key}"
name = "nva-landing-${each.key}"
service_label = var.prefix
forwarding_rules_config = {
"" = {
@ -170,8 +174,8 @@ module "ilb-nva-trusted" {
}
}
vpc_config = {
network = module.landing-trusted-vpc.self_link
subnetwork = module.landing-trusted-vpc.subnet_self_links[each.value.subnet]
network = module.landing-vpc.self_link
subnetwork = try(module.landing-vpc.subnet_self_links[each.value.subnet], null)
}
backends = [
for k, v in module.nva-mig :

View File

@ -31,10 +31,10 @@ locals {
vpc_self_links = local.vpc_self_links
}
vpc_self_links = {
prod-landing-trusted = module.landing-trusted-vpc.self_link
prod-landing-untrusted = module.landing-untrusted-vpc.self_link
dev-spoke-0 = module.dev-spoke-vpc.self_link
prod-spoke-0 = module.prod-spoke-vpc.self_link
prod-landing = module.landing-vpc.self_link
prod-dmz = module.dmz-vpc.self_link
dev-spoke-0 = module.dev-spoke-vpc.self_link
prod-spoke-0 = module.prod-spoke-vpc.self_link
}
}

View File

@ -16,16 +16,16 @@
# tfdoc:file:description temporary instances for testing
# # Untrusted (Landing)
# # dmz (Landing)
# module "test-vm-landing-untrusted-primary-0" {
# module "test-vm-dmz-primary-0" {
# source = "../../../modules/compute-vm"
# project_id = module.landing-project.project_id
# zone = "${var.regions.primary}-b"
# name = "test-vm-lnd-unt-pri-0"
# network_interfaces = [{
# network = module.landing-untrusted-vpc.self_link
# subnetwork = module.landing-untrusted-vpc.subnet_self_links["${var.regions.primary}/landing-untrusted-default-${local.region_shortnames[var.regions.primary]}"]
# network = module.dmz-vpc.self_link
# subnetwork = module.dmz-vpc.subnet_self_links["${var.regions.primary}/dmz-default-${local.region_shortnames[var.regions.primary]}"]
# }]
# tags = ["primary", "ssh"]
# service_account_create = true
@ -46,14 +46,14 @@
# }
# }
# module "test-vm-landing-untrusted-secondary-0" {
# module "test-vm-dmz-secondary-0" {
# source = "../../../modules/compute-vm"
# project_id = module.landing-project.project_id
# zone = "${var.regions.secondary}-a"
# name = "test-vm-lnd-unt-sec-0"
# network_interfaces = [{
# network = module.landing-untrusted-vpc.self_link
# subnetwork = module.landing-untrusted-vpc.subnet_self_links["${var.regions.secondary}/landing-untrusted-default-${local.region_shortnames[var.regions.secondary]}"]
# network = module.dmz-vpc.self_link
# subnetwork = module.dmz-vpc.subnet_self_links["${var.regions.secondary}/dmz-default-${local.region_shortnames[var.regions.secondary]}"]
# }]
# tags = ["secondary", "ssh"]
# service_account_create = true
@ -74,16 +74,16 @@
# }
# }
# # Trusted (hub)
# # landing (hub)
# module "test-vm-landing-trusted-primary-0" {
# module "test-vm-landing-primary-0" {
# source = "../../../modules/compute-vm"
# project_id = module.landing-project.project_id
# zone = "${var.regions.primary}-b"
# name = "test-vm-lnd-tru-pri-0"
# network_interfaces = [{
# network = module.landing-trusted-vpc.self_link
# subnetwork = module.landing-trusted-vpc.subnet_self_links["${var.regions.primary}/landing-trusted-default-${local.region_shortnames[var.regions.primary]}"]
# network = module.landing-vpc.self_link
# subnetwork = module.landing-vpc.subnet_self_links["${var.regions.primary}/landing-default-${local.region_shortnames[var.regions.primary]}"]
# }]
# tags = ["primary", "ssh"]
# service_account_create = true
@ -104,14 +104,14 @@
# }
# }
# module "test-vm-landing-trusted-secondary-0" {
# module "test-vm-landing-secondary-0" {
# source = "../../../modules/compute-vm"
# project_id = module.landing-project.project_id
# zone = "${var.regions.secondary}-a"
# name = "test-vm-lnd-tru-sec-0"
# network_interfaces = [{
# network = module.landing-trusted-vpc.self_link
# subnetwork = module.landing-trusted-vpc.subnet_self_links["${var.regions.secondary}/landing-trusted-default-${local.region_shortnames[var.regions.secondary]}"]
# network = module.landing-vpc.self_link
# subnetwork = module.landing-vpc.subnet_self_links["${var.regions.secondary}/landing-default-${local.region_shortnames[var.regions.secondary]}"]
# }]
# tags = ["secondary", "ssh"]
# service_account_create = true

View File

@ -127,14 +127,14 @@ variable "gcp_ranges" {
description = "GCP address ranges in name => range format."
type = map(string)
default = {
gcp_dev_primary = "10.68.0.0/16"
gcp_dev_secondary = "10.84.0.0/16"
gcp_landing_trusted_primary = "10.64.0.0/17"
gcp_landing_trusted_secondary = "10.80.0.0/17"
gcp_landing_untrusted_primary = "10.64.127.0/17"
gcp_landing_untrusted_secondary = "10.80.127.0/17"
gcp_prod_primary = "10.72.0.0/16"
gcp_prod_secondary = "10.88.0.0/16"
gcp_dev_primary = "10.68.0.0/16"
gcp_dev_secondary = "10.84.0.0/16"
gcp_landing_landing_primary = "10.64.0.0/17"
gcp_landing_landing_secondary = "10.80.0.0/17"
gcp_dmz_primary = "10.64.127.0/17"
gcp_dmz_secondary = "10.80.127.0/17"
gcp_prod_primary = "10.72.0.0/16"
gcp_prod_secondary = "10.88.0.0/16"
}
}

View File

@ -31,7 +31,7 @@ module "landing-to-onprem-primary-vpn" {
count = var.vpn_onprem_primary_config == null ? 0 : 1
source = "../../../modules/net-vpn-ha"
project_id = module.landing-project.project_id
network = module.landing-trusted-vpc.self_link
network = module.landing-vpc.self_link
region = var.regions.primary
name = "vpn-to-onprem-${local.region_shortnames[var.regions.primary]}"
router_config = try(var.vpn_onprem_primary_config.router_config, {})
@ -45,7 +45,7 @@ module "landing-to-onprem-secondary-vpn" {
count = var.vpn_onprem_secondary_config == null ? 0 : 1
source = "../../../modules/net-vpn-ha"
project_id = module.landing-project.project_id
network = module.landing-trusted-vpc.self_link
network = module.landing-vpc.self_link
region = var.regions.secondary
name = "vpn-to-onprem-${local.region_shortnames[var.regions.secondary]}"
router_config = try(var.vpn_onprem_secondary_config.router_config, {})

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-dataplatform
region: europe-west1
description: Default subnet for dev Data Platform
ip_cidr_range: 10.68.2.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-default
region: europe-west1
ip_cidr_range: 10.68.0.0/24
description: Default subnet for dev

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-gke-nodes
region: europe-west1
description: Default subnet for prod gke nodes
ip_cidr_range: 10.68.1.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: prod-default
region: europe-west1
ip_cidr_range: 10.72.0.0/24
description: Default subnet for prod

View File

@ -33,11 +33,6 @@ module "dev-dns-private-zone" {
}
}
moved {
from = module.dev-onprem-example-dns-forwarding
to = module.dev-dns-fwd-onprem-example
}
module "dev-dns-fwd-onprem-example" {
source = "../../../modules/dns"
count = length(var.dns.dev_resolvers) > 0 ? 1 : 0
@ -52,11 +47,6 @@ module "dev-dns-fwd-onprem-example" {
}
}
moved {
from = module.dev-reverse-10-dns-forwarding
to = module.dev-dns-fwd-onprem-rev-10
}
module "dev-dns-fwd-onprem-rev-10" {
source = "../../../modules/dns"
count = length(var.dns.dev_resolvers) > 0 ? 1 : 0

View File

@ -33,11 +33,6 @@ module "prod-dns-private-zone" {
}
}
moved {
from = module.prod-onprem-example-dns-forwarding
to = module.prod-dns-fwd-onprem-example
}
module "prod-dns-fwd-onprem-example" {
source = "../../../modules/dns"
count = length(var.dns.prod_resolvers) > 0 ? 1 : 0
@ -52,11 +47,6 @@ module "prod-dns-fwd-onprem-example" {
}
}
moved {
from = module.prod-reverse-10-dns-forwarding
to = module.prod-dns-fwd-onprem-rev-10
}
module "prod-dns-fwd-onprem-rev-10" {
source = "../../../modules/dns"
count = length(var.dns.prod_resolvers) > 0 ? 1 : 0

View File

@ -80,20 +80,20 @@ In case of a regional failure, the corresponding dynamic routes are withdrawn an
The "landing zone" is divided into two VPC networks:
- the trusted VPC: the connectivity hub towards other trusted networks
- the untrusted VPC: the connectivity hub towards any other untrusted network
- the landing VPC: the connectivity hub towards other trusted networks
- the DMZ VPC: the connectivity hub towards any other untrusted network
### NCC, NVAs and BGP sessions
The VPCs connect through two sets of sample NVA machines: one per region, each containing two instances. The appliances run [Container-Optimized OS](https://cloud.google.com/container-optimized-os/docs) and a container with [FRRouting](https://frrouting.org/).
We levarage NCC-RA to allow the NVAs to establish BGP sessions with Cloud Routers in the untrusted and in the trusted VPCs. This allows Cloud Routers to advertise routes to the NVAs, and the NVAs to announce routes to the Cloud Router, so it can program them in the VPC.
We leverage NCC-RA to allow the NVAs to establish BGP sessions with Cloud Routers in the untrusted and in the trusted VPCs. This allows Cloud Routers to advertise routes to the NVAs, and the NVAs to announce routes to the Cloud Router, so it can program them in the VPC.
Specifically, each NVA establishes two BGP sessions (for redundancy) with the the Cloud Router deployed in the VPC and in the subnet where the interface of that VM is attached to.
**Cloud Routers in the untrusted VPC advertise the default route (0.0.0.0/0) to the NVAs**. The NVAs advertise the route to the Cloud Routers in the trusted VPC. These dynamic routes are then imported through VPC peerings in the spokes.
**Cloud Routers in the DMZ VPC advertise the default route (0.0.0.0/0) to the NVAs**. The NVAs advertise the route to the Cloud Routers in the landing. These dynamic routes are then imported through VPC peerings in the spokes.
**Cloud Routers in the trusted hub adverts to the NVAs** all the subnets of the trusted VPCs. This includes the regional subnets and the cross-regional subnets. The NVAs manipulate the route costs (MED) before advertising them to the Cloud Routers in the untrusted VPC. This is done to guarantee symmetric traffic paths (more [here](https://medium.com/google-cloud/gcp-routing-adventures-vol-2-enterprise-multi-regional-deployments-in-google-cloud-3968e9591d59)).
**Cloud Routers in the landing adverts to the NVAs** all the subnets of the trusted VPCs. This includes the regional subnets and the cross-regional subnets. The NVAs manipulate the route costs (MED) before advertising them to the Cloud Routers in the DMZ VPC. This is done to guarantee symmetric traffic paths (more [here](https://medium.com/google-cloud/gcp-routing-adventures-vol-2-enterprise-multi-regional-deployments-in-google-cloud-3968e9591d59)).
NVAs establish **extra BGP sessions with both cross-regional NVAs**. In this case, the NVAs advertise the regional trusted routes only. This allows cross-spoke (environment) traffic to remain also symmetric (more [here](https://medium.com/google-cloud/gcp-routing-adventures-vol-2-enterprise-multi-regional-deployments-in-google-cloud-3968e9591d59)). We set these routes to be exchanged at a lower cost than the one set for the other routes.
@ -101,8 +101,8 @@ Following the majority of real-life deployments, **we assume appliances to be st
By default, the design assumes that:
- on-premise networks (and related resources) are considered trusted. As such, the VPNs connecting with on-premises are terminated in GCP, in the trusted VPC
- the public Internet is considered untrusted. As such [Cloud NAT](https://cloud.google.com/nat/docs/overview) is deployed in the untrusted landing VPC only. Also, the default route is set to carry traffic from the trusted VPCs, through the NVAs, to the untrusted VPC.
- on-premise networks (and related resources) are considered trusted. As such, the VPNs connecting with on-premises are terminated in GCP, in the landing
- the public Internet is considered untrusted. As such [Cloud NAT](https://cloud.google.com/nat/docs/overview) is deployed in the DMZ VPC only. Also, the default route is set to carry traffic from the trusted VPCs, through the NVAs, to the DMZ.
- cross-spoke (environment) traffic and traffic from any untrusted network to any trusted network (and vice versa) pass through the NVAs.
- any traffic from a trusted network to an untrusted network (e.g. Internet) is natted by the NVAs. Users can configure further exclusions.
@ -133,7 +133,7 @@ This is an options summary:
- [VPC Peering](https://cloud.google.com/vpc/docs/vpc-peering) (used here to connect the trusted landing VPC with the spokes, also used by [02-networking-vpn](../2-networking-b-vpn/))
- Pros: no additional costs, full bandwidth with no configurations, no extra latency
- Cons: no transitivity (e.g. to GKE masters, Cloud SQL, etc.), no selective exchange of routes, several quotas and limits shared between VPCs in a peering group
- [Multi-NIC appliances](https://cloud.google.com/architecture/best-practices-vpc-design#multi-nic) (used here to connect the trusted landing and untrusted VPCs)
- [Multi-NIC appliances](https://cloud.google.com/architecture/best-practices-vpc-design#multi-nic) (used here to connect the trusted landing and DMZ)
- Pros: provides additional security features (e.g. IPS), potentially better integration with on-prem systems by using the same vendor
- Cons: complex HA/failover setup, limited by VM bandwidth and scale, additional costs for VMs and licenses, out of band management of a critical cloud component
- [HA VPN](https://cloud.google.com/network-connectivity/docs/vpn/concepts/topologies)
@ -154,10 +154,10 @@ This is a summary of the subnets allocated by default in this setup:
| name | description | CIDR |
|---|---|---|
| landing-trusted-default-ew1 | Trusted landing subnet - europe-west1 | 10.128.64.0/24 |
| landing-trusted-default-ew4 | Trusted landing subnet - europe-west4 | 10.128.96.0/24 |
| landing-untrusted-default-ew1 | Untrusted landing subnet - europe-west1 | 10.128.0.0/24 |
| landing-untrusted-default-ew4 | Untrusted landing subnet - europe-west4 | 10.128.32.0/24 |
| landing-default-ew1 | Trusted landing subnet - europe-west1 | 10.128.64.0/24 |
| landing-default-ew4 | Trusted landing subnet - europe-west4 | 10.128.96.0/24 |
| dmz-default-ew1 | Untrusted landing subnet - europe-west1 | 10.128.0.0/24 |
| dmz-default-ew4 | Untrusted landing subnet - europe-west4 | 10.128.32.0/24 |
| dev-default-ew1 | Dev spoke subnet - europe-west1 | 10.68.0.0/24 |
| dev-default-ew1 | Free (PSA) - europe-west1 | 10.68.253.0/24 |
| dev-default-ew1 | Free (PSA) - europe-west1 | 10.68.254.0/24 |
@ -183,10 +183,10 @@ In this setup:
- routes between multiple subnets within the same VPC are automatically exchanged by GCP
- the spokes and the trusted landing VPC exchange dynamic routes through VPC peerings
- on-premises is connected to the trusted landing VPC and it dynamically exchanges BGP routes with GCP (with the trusted VPC) using HA VPN
- the NVAs exchange dynamic routes using BGP with Cloud Routers in the untrusted VPC, Cloud Routers in the trusted VPC and cross-regional NVAs. This allows VMs in different environments and different regions to communicate.
- on-premises is connected to the trusted landing VPC and it dynamically exchanges BGP routes with GCP (with the landing) using HA VPN
- the NVAs exchange dynamic routes using BGP with Cloud Routers in the DMZ, Cloud Routers in the landing and cross-regional NVAs. This allows VMs in different environments and different regions to communicate.
The Cloud Routers (connected to the VPN gateways in the trusted VPC) are configured to exclude the default advertisement of VPC ranges and they only advertise their respective aggregate ranges, via custom advertisements. This greatly simplifies the routing configuration and avoids quota or limit issues, by keeping the number of routes small, instead of making it proportional to the subnets and to the secondary ranges in the VPCs.
The Cloud Routers (connected to the VPN gateways in the landing) are configured to exclude the default advertisement of VPC ranges and they only advertise their respective aggregate ranges, via custom advertisements. This greatly simplifies the routing configuration and avoids quota or limit issues, by keeping the number of routes small, instead of making it proportional to the subnets and to the secondary ranges in the VPCs.
### Internet egress
@ -253,14 +253,14 @@ Each VPC network ([`net-vpc`](../../../modules/net-vpc)) manages a separate rout
NCC/Cloud Router BGP settings are defined in `ncc.tf`.
NVA BGP settings are defined in the [bpg-config.tftpl template file](./data/bgp-config.tftpl).
The variable `ncc_asn` allows to change the Autonomous System Number (ASN) assigned to the untrusted VPC Cloud Routers, to the trusted VPC Cloud Routers and to the NVAs.
The variable `ncc_asn` allows to change the Autonomous System Number (ASN) assigned to the DMZ Cloud Routers, to the landing VPC Cloud Routers and to the NVAs.
BGP sessions for trusted landing to on-premises are configured through the variable `vpn_onprem_configs`.
### Firewall
**VPC firewall rules** ([`net-vpc-firewall`](../../../modules/net-vpc-firewall)) are defined per-vpc on each `vpc-*.tf` file and leverage a resource factory to massively create rules.
To add a new firewall rule, create a new file or edit an existing one in the `data_folder` directory defined in the module `net-vpc-firewall`, following the examples of the "[Rules factory](../../../modules/net-vpc-firewall#rules-factory)" section of the module documentation. Sample firewall rules are shipped in [data/firewall-rules/landing-untrusted](./data/firewall-rules/landing-untrusted) and in [data/firewall-rules/landing-trusted](./data/firewall-rules/landing-trusted), and can be easily customized.
To add a new firewall rule, create a new file or edit an existing one in the `data_folder` directory defined in the module `net-vpc-firewall`, following the examples of the "[Rules factory](../../../modules/net-vpc-firewall#rules-factory)" section of the module documentation. Sample firewall rules are shipped in [data/firewall-rules/landing-untrusted](./data/firewall-rules/dmz) and in [data/firewall-rules/landing-trusted](./data/firewall-rules/landing), and can be easily customized.
**Hierarchical firewall policies** ([`folder`](../../../modules/folder)) are defined in `main.tf` and managed through a policy factory implemented by the `net-firewall-policy` module, which is then applied to the `Networking` folder containing all the core networking infrastructure. Policies are defined in the `rules_file` file, to define a new one simply use the [firewall policy module documentation](../../../modules/net-firewall-policy/README.md#factory)". Sample hierarchical firewall rules are shipped in [data/hierarchical-ingress-rules.yaml](./data/hierarchical-ingress-rules.yaml) and can be easily customised.
@ -493,8 +493,8 @@ DNS configurations are centralised in the `dns-*.tf` files. Spokes delegate DNS
| [enable_cloud_nat](variables.tf#L82) | Deploy Cloud NAT. | <code>bool</code> | | <code>false</code> | |
| [essential_contacts](variables.tf#L89) | Email used for essential contacts, unset if null. | <code>string</code> | | <code>null</code> | |
| [factories_config](variables.tf#L95) | Configuration for network resource factories. | <code title="object&#40;&#123;&#10; data_dir &#61; optional&#40;string, &#34;data&#34;&#41;&#10; dns_policy_rules_file &#61; optional&#40;string, &#34;data&#47;dns-policy-rules.yaml&#34;&#41;&#10; firewall_policy_name &#61; optional&#40;string, &#34;net-default&#34;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; data_dir &#61; &#34;data&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [gcp_ranges](variables.tf#L126) | GCP address ranges in name => range format. | <code>map&#40;string&#41;</code> | | <code title="&#123;&#10; gcp_dev_primary &#61; &#34;10.68.0.0&#47;16&#34;&#10; gcp_dev_secondary &#61; &#34;10.84.0.0&#47;16&#34;&#10; gcp_landing_trusted_primary &#61; &#34;10.64.0.0&#47;17&#34;&#10; gcp_landing_trusted_secondary &#61; &#34;10.80.0.0&#47;17&#34;&#10; gcp_landing_untrusted_primary &#61; &#34;10.64.127.0&#47;17&#34;&#10; gcp_landing_untrusted_secondary &#61; &#34;10.80.127.0&#47;17&#34;&#10; gcp_prod_primary &#61; &#34;10.72.0.0&#47;16&#34;&#10; gcp_prod_secondary &#61; &#34;10.88.0.0&#47;16&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [ncc_asn](variables.tf#L141) | The NCC Cloud Routers ASN configuration. | <code>map&#40;number&#41;</code> | | <code title="&#123;&#10; nva_primary &#61; 64513&#10; nva_secondary &#61; 64514&#10; trusted &#61; 64515&#10; untrusted &#61; 64512&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [gcp_ranges](variables.tf#L126) | GCP address ranges in name => range format. | <code>map&#40;string&#41;</code> | | <code title="&#123;&#10; gcp_dev_primary &#61; &#34;10.68.0.0&#47;16&#34;&#10; gcp_dev_secondary &#61; &#34;10.84.0.0&#47;16&#34;&#10; gcp_landing_primary &#61; &#34;10.64.0.0&#47;17&#34;&#10; gcp_landing_secondary &#61; &#34;10.80.0.0&#47;17&#34;&#10; gcp_dmz_primary &#61; &#34;10.64.127.0&#47;17&#34;&#10; gcp_dmz_secondary &#61; &#34;10.80.127.0&#47;17&#34;&#10; gcp_prod_primary &#61; &#34;10.72.0.0&#47;16&#34;&#10; gcp_prod_secondary &#61; &#34;10.88.0.0&#47;16&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [ncc_asn](variables.tf#L141) | The NCC Cloud Routers ASN configuration. | <code>map&#40;number&#41;</code> | | <code title="&#123;&#10; nva_primary &#61; 64513&#10; nva_secondary &#61; 64514&#10; landing &#61; 64515&#10; dmz &#61; 64512&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [onprem_cidr](variables.tf#L152) | Onprem addresses in name => range format. | <code>map&#40;string&#41;</code> | | <code title="&#123;&#10; main &#61; &#34;10.0.0.0&#47;24&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [outputs_location](variables.tf#L170) | Path where providers and tfvars files for the following stages are written. Leave empty to disable. | <code>string</code> | | <code>null</code> | |
| [psa_ranges](variables.tf#L187) | IP ranges used for Private Service Access (e.g. CloudSQL). Ranges is in name => range format. | <code title="object&#40;&#123;&#10; dev &#61; object&#40;&#123;&#10; ranges &#61; map&#40;string&#41;&#10; export_routes &#61; optional&#40;bool, false&#41;&#10; import_routes &#61; optional&#40;bool, false&#41;&#10; peered_domains &#61; optional&#40;list&#40;string&#41;, &#91;&#93;&#41;&#10; &#125;&#41;&#10; prod &#61; object&#40;&#123;&#10; ranges &#61; map&#40;string&#41;&#10; export_routes &#61; optional&#40;bool, false&#41;&#10; import_routes &#61; optional&#40;bool, false&#41;&#10; peered_domains &#61; optional&#40;list&#40;string&#41;, &#91;&#93;&#41;&#10; &#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> | |

View File

@ -5,27 +5,27 @@ no ipv6 forwarding
service integrated-vtysh-config
interface lo
ip address ${ip_untrusted}/32
ip address ${ip_dmz}/32
ip prefix-list DEFAULT seq 10 permit 0.0.0.0/0
!
ip prefix-list PRIMARY seq 10 permit ${gcp_landing_trusted_primary}
ip prefix-list PRIMARY seq 10 permit ${gcp_landing_landing_primary}
ip prefix-list PRIMARY seq 20 permit ${gcp_dev_primary}
ip prefix-list PRIMARY seq 30 permit ${gcp_prod_primary}
!
ip prefix-list SECONDARY seq 10 permit ${gcp_landing_trusted_secondary}
ip prefix-list SECONDARY seq 10 permit ${gcp_landing_landing_secondary}
ip prefix-list SECONDARY seq 20 permit ${gcp_dev_secondary}
ip prefix-list SECONDARY seq 30 permit ${gcp_prod_secondary}
route-map TO-UNTRUSTED permit 10
route-map TO-DMZ permit 10
match ip address prefix-list PRIMARY
set metric ${cost_primary}
!
route-map TO-UNTRUSTED permit 20
route-map TO-DMZ permit 20
match ip address prefix-list SECONDARY
set metric ${cost_secondary}
!
route-map TO-TRUSTED permit 10
route-map TO-LANDING permit 10
match ip address prefix-list DEFAULT
set metric 100
!
@ -34,7 +34,7 @@ route-map TO-NVA permit 10
set metric 50
router bgp ${asn_nva}
bgp router-id ${ip_untrusted}
bgp router-id ${ip_dmz}
bgp bestpath as-path ignore
bgp disable-ebgp-connected-route-check
bgp timers 20 60
@ -42,13 +42,13 @@ router bgp ${asn_nva}
no bgp ebgp-requires-policy
no bgp network import-check
!
neighbor ${ip_neighbor_untrusted_0} remote-as ${asn_untrusted}
neighbor ${ip_neighbor_untrusted_1} remote-as ${asn_untrusted}
neighbor ${ip_neighbor_dmz_0} remote-as ${asn_dmz}
neighbor ${ip_neighbor_dmz_1} remote-as ${asn_dmz}
!
neighbor ${ip_neighbor_trusted_0} remote-as ${asn_trusted}
neighbor ${ip_neighbor_trusted_0} update-source ${ip_trusted}
neighbor ${ip_neighbor_trusted_1} remote-as ${asn_trusted}
neighbor ${ip_neighbor_trusted_1} update-source ${ip_trusted}
neighbor ${ip_neighbor_landing_0} remote-as ${asn_landing}
neighbor ${ip_neighbor_landing_0} update-source ${ip_landing}
neighbor ${ip_neighbor_landing_1} remote-as ${asn_landing}
neighbor ${ip_neighbor_landing_1} update-source ${ip_landing}
!
neighbor ${ip_neighbor_cross_region_nva_0} remote-as ${asn_nva_cross_region}
neighbor ${ip_neighbor_cross_region_nva_0} ebgp-multihop 2
@ -56,17 +56,17 @@ router bgp ${asn_nva}
neighbor ${ip_neighbor_cross_region_nva_1} ebgp-multihop 2
!
address-family ipv4 unicast
neighbor ${ip_neighbor_untrusted_0} route-map TO-UNTRUSTED out
neighbor ${ip_neighbor_untrusted_0} soft-reconfiguration inbound
neighbor ${ip_neighbor_dmz_0} route-map TO-DMZ out
neighbor ${ip_neighbor_dmz_0} soft-reconfiguration inbound
!
neighbor ${ip_neighbor_untrusted_1} route-map TO-UNTRUSTED out
neighbor ${ip_neighbor_untrusted_1} soft-reconfiguration inbound
neighbor ${ip_neighbor_dmz_1} route-map TO-DMZ out
neighbor ${ip_neighbor_dmz_1} soft-reconfiguration inbound
!
neighbor ${ip_neighbor_trusted_0} route-map TO-TRUSTED out
neighbor ${ip_neighbor_trusted_0} soft-reconfiguration inbound
neighbor ${ip_neighbor_landing_0} route-map TO-LANDING out
neighbor ${ip_neighbor_landing_0} soft-reconfiguration inbound
!
neighbor ${ip_neighbor_trusted_1} route-map TO-TRUSTED out
neighbor ${ip_neighbor_trusted_1} soft-reconfiguration inbound
neighbor ${ip_neighbor_landing_1} route-map TO-LANDING out
neighbor ${ip_neighbor_landing_1} soft-reconfiguration inbound
!
neighbor ${ip_neighbor_cross_region_nva_0} route-map TO-NVA out
neighbor ${ip_neighbor_cross_region_nva_0} soft-reconfiguration inbound

View File

@ -9,13 +9,13 @@ healthchecks:
- 209.85.152.0/22
- 209.85.204.0/22
ncc_cloud_routers_trusted:
ncc_cloud_routers_landing:
- 10.128.64.201/32
- 10.128.64.202/32
- 10.128.96.201/32
- 10.128.96.202/32
ncc_cloud_routers_untrusted:
ncc_cloud_routers_dmz:
- 10.128.0.201/32
- 10.128.0.202/32
- 10.128.32.201/32

View File

@ -1,7 +1,7 @@
# skip boilerplate check
ingress:
untrusted-ingress-default-deny:
dmz-ingress-default-deny:
description: "Deny and log any unmatched ingress traffic."
deny: true
priority: 65535

View File

@ -4,7 +4,7 @@
# You can retain `---` (start of the document) to indicate an empty document.
ingress:
allow-hc-nva-ssh-untrusted:
allow-hc-nva-ssh-dmz:
description: "Allow traffic from Google healthchecks to NVA appliances"
source_ranges:
- healthchecks
@ -15,16 +15,16 @@ ingress:
# these are not really needed, but it's good to have them
# in place if the more generic hierarchical firewall policies
# get deleted
allow-ncc-nva-bgp-untrusted:
allow-ncc-nva-bgp-dmz:
description: "Allow BGP traffic from NCC Cloud Routers to NVAs"
source_ranges:
- ncc_cloud_routers_untrusted
- ncc_cloud_routers_dmz
targets: ["nva"]
rules:
- protocol: tcp
ports:
- 179
allow-nva-nva-bgp-untrusted:
allow-nva-nva-bgp-dmz:
description: "Allow BGP traffic from cross-regional NVAs"
sources: ["nva"]
targets: ["nva"]

View File

@ -1,7 +1,7 @@
# skip boilerplate check
ingress:
untrusted-ingress-default-deny:
landing-ingress-default-deny:
description: "Deny and log any unmatched ingress traffic."
deny: true
priority: 65535

View File

@ -4,7 +4,7 @@
# You can retain `---` (start of the document) to indicate an empty document.
ingress:
allow-hc-nva-ssh-trusted:
allow-hc-nva-ssh-landing:
description: "Allow traffic from Google healthchecks to NVA appliances"
source_ranges:
- healthchecks
@ -12,7 +12,7 @@ ingress:
- protocol: tcp
ports:
- 22
allow-onprem-probes-trusted-example:
allow-onprem-probes-landing-example:
description: "Allow traffic from onprem probes"
source_ranges:
- onprem_probes
@ -23,10 +23,10 @@ ingress:
# This is not really needed, but it's good to have it
# in place if the more generic hierarchical firewall policies
# get deleted
allow-ncc-nva-bgp-trusted:
allow-ncc-nva-bgp-landing:
description: "Allow BGP traffic from NCC Cloud Routers to NVAs"
source_ranges:
- ncc_cloud_routers_trusted
- ncc_cloud_routers_landing
targets: ["nva"]
rules:
- protocol: tcp

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-dataplatform
region: europe-west1
description: Default subnet for dev Data Platform
ip_cidr_range: 10.68.2.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-default
region: europe-west1
ip_cidr_range: 10.68.0.0/24
description: Default europe-west1 subnet for dev

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-default
region: europe-west4
ip_cidr_range: 10.84.0.0/24
description: Default europe-west4 subnet for dev

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dev-gke-nodes
region: europe-west1
description: Default subnet for prod gke nodes
ip_cidr_range: 10.68.1.0/24

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dmz-default
region: europe-west1
ip_cidr_range: 10.64.128.0/24
description: Default europe-west1 subnet for landing untrusted
description: Default europe-west1 subnet for DMZ

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: dmz-default
region: europe-west4
ip_cidr_range: 10.80.128.0/24
description: Default europe-west4 subnet for landing untrusted
description: Default europe-west4 subnet for DMZ

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: landing-default
region: europe-west1
ip_cidr_range: 10.64.0.0/24
description: Default europe-west1 subnet for landing trusted
description: Default europe-west1 subnet for landing

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: landing-default
region: europe-west4
ip_cidr_range: 10.80.0.0/24
description: Default europe-west4 subnet for landing trusted
description: Default europe-west4 subnet for landing

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: prod-default
region: europe-west1
ip_cidr_range: 10.72.0.0/24
description: Default europe-west1 subnet for prod

View File

@ -1,5 +1,6 @@
# skip boilerplate check
name: prod-default
region: europe-west4
ip_cidr_range: 10.88.0.0/24
description: Default europe-west4 subnet for prod

View File

@ -25,7 +25,7 @@ module "dev-dns-private-zone" {
zone_config = {
domain = "dev.gcp.example.com."
private = {
client_networks = [module.landing-trusted-vpc.self_link, module.landing-untrusted-vpc.self_link]
client_networks = [module.landing-vpc.self_link, module.dmz-vpc.self_link]
}
}
recordsets = {
@ -48,7 +48,7 @@ module "dev-dns-peer-landing-root" {
domain = "."
peering = {
client_networks = [module.dev-spoke-vpc.self_link]
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}
}
}
@ -66,7 +66,7 @@ module "dev-dns-peer-landing-rev-10" {
domain = "10.in-addr.arpa."
peering = {
client_networks = [module.dev-spoke-vpc.self_link]
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}
}
}

View File

@ -32,8 +32,8 @@ module "landing-dns-fwd-onprem-example" {
domain = "onprem.example.com."
forwarding = {
client_networks = [
module.landing-untrusted-vpc.self_link,
module.landing-trusted-vpc.self_link
module.dmz-vpc.self_link,
module.landing-vpc.self_link
]
forwarders = { for ip in var.dns.resolvers : ip => null }
}
@ -54,8 +54,8 @@ module "landing-dns-fwd-onprem-rev-10" {
domain = "10.in-addr.arpa."
forwarding = {
client_networks = [
module.landing-untrusted-vpc.self_link,
module.landing-trusted-vpc.self_link
module.dmz-vpc.self_link,
module.landing-vpc.self_link
]
forwarders = { for ip in var.dns.resolvers : ip => null }
}
@ -75,8 +75,8 @@ module "landing-dns-priv-gcp" {
domain = "gcp.example.com."
private = {
client_networks = [
module.landing-untrusted-vpc.self_link,
module.landing-trusted-vpc.self_link
module.dmz-vpc.self_link,
module.landing-vpc.self_link
]
}
}
@ -95,7 +95,7 @@ module "landing-dns-policy-googleapis" {
rules = var.factories_config.dns_policy_rules_file
}
networks = {
landing-trusted = module.landing-trusted-vpc.self_link
landing-untrusted = module.landing-untrusted-vpc.self_link
landing = module.landing-vpc.self_link
dmz = module.dmz-vpc.self_link
}
}

View File

@ -25,7 +25,7 @@ module "prod-dns-private-zone" {
zone_config = {
domain = "prod.gcp.example.com."
private = {
client_networks = [module.landing-trusted-vpc.self_link, module.landing-untrusted-vpc.self_link]
client_networks = [module.landing-vpc.self_link, module.dmz-vpc.self_link]
}
}
recordsets = {
@ -48,7 +48,7 @@ module "prod-dns-peer-landing-root" {
domain = "."
peering = {
client_networks = [module.prod-spoke-vpc.self_link]
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}
}
}
@ -66,7 +66,7 @@ module "prod-dns-peer-landing-rev-10" {
domain = "10.in-addr.arpa."
peering = {
client_networks = [module.prod-spoke-vpc.self_link]
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}
}
}

View File

@ -22,8 +22,8 @@ locals {
regions = distinct(concat(
values(var.regions),
values(module.dev-spoke-vpc.subnet_regions),
values(module.landing-trusted-vpc.subnet_regions),
values(module.landing-untrusted-vpc.subnet_regions),
values(module.landing-vpc.subnet_regions),
values(module.dmz-vpc.subnet_regions),
values(module.prod-spoke-vpc.subnet_regions),
))
service_accounts = {

View File

@ -14,28 +14,28 @@
* limitations under the License.
*/
resource "google_network_connectivity_hub" "hub_trusted" {
name = "prod-hub-trusted"
description = "Prod hub trusted"
resource "google_network_connectivity_hub" "hub_landing" {
name = "prod-hub-landing"
description = "Prod hub landing (trusted)"
project = module.landing-project.project_id
}
resource "google_network_connectivity_hub" "hub_untrusted" {
name = "prod-hub-untrusted"
description = "Prod hub untrusted"
resource "google_network_connectivity_hub" "hub_dmz" {
name = "prod-hub-dmz"
description = "Prod hub DMZ (untrusted)"
project = module.landing-project.project_id
}
module "spokes-trusted" {
module "spokes-landing" {
for_each = var.regions
source = "../../../modules/ncc-spoke-ra"
name = "prod-spoke-trusted-${local.region_shortnames[each.value]}"
name = "prod-spoke-landing-${local.region_shortnames[each.value]}"
project_id = module.landing-project.project_id
region = each.value
hub = {
create = false,
id = google_network_connectivity_hub.hub_trusted.id
id = google_network_connectivity_hub.hub_landing.id
}
router_appliances = [
@ -47,9 +47,13 @@ module "spokes-trusted" {
]
router_config = {
asn = var.ncc_asn.trusted
ip_interface0 = cidrhost(module.landing-trusted-vpc.subnet_ips["${each.value}/landing-trusted-default-${local.region_shortnames[each.value]}"], 201)
ip_interface1 = cidrhost(module.landing-trusted-vpc.subnet_ips["${each.value}/landing-trusted-default-${local.region_shortnames[each.value]}"], 202)
asn = var.ncc_asn.landing
ip_interface0 = cidrhost(
module.landing-vpc.subnet_ips["${each.value}/landing-default"], 201
)
ip_interface1 = cidrhost(
module.landing-vpc.subnet_ips["${each.value}/landing-default"], 202
)
peer_asn = (
each.key == "primary"
? var.ncc_asn.nva_primary
@ -60,32 +64,32 @@ module "spokes-trusted" {
custom_advertise = {
all_subnets = false
ip_ranges = {
"${var.gcp_ranges.gcp_landing_trusted_primary}" = "GCP landing trusted primary."
"${var.gcp_ranges.gcp_landing_trusted_secondary}" = "GCP landing trusted secondary."
"${var.gcp_ranges.gcp_dev_primary}" = "GCP dev primary.",
"${var.gcp_ranges.gcp_dev_secondary}" = "GCP dev secondary.",
"${var.gcp_ranges.gcp_prod_primary}" = "GCP prod primary.",
"${var.gcp_ranges.gcp_prod_secondary}" = "GCP prod secondary.",
"${var.gcp_ranges.gcp_landing_primary}" = "GCP landing primary."
"${var.gcp_ranges.gcp_landing_secondary}" = "GCP landing secondary."
"${var.gcp_ranges.gcp_dev_primary}" = "GCP dev primary.",
"${var.gcp_ranges.gcp_dev_secondary}" = "GCP dev secondary.",
"${var.gcp_ranges.gcp_prod_primary}" = "GCP prod primary.",
"${var.gcp_ranges.gcp_prod_secondary}" = "GCP prod secondary.",
}
}
}
vpc_config = {
network_name = module.landing-trusted-vpc.self_link
subnet_self_link = module.landing-trusted-vpc.subnet_self_links["${each.value}/landing-trusted-default-${local.region_shortnames[each.value]}"]
network_name = module.landing-vpc.self_link
subnet_self_link = module.landing-vpc.subnet_self_links["${each.value}/landing-default"]
}
}
module "spokes-untrusted" {
module "spokes-dmz" {
for_each = var.regions
source = "../../../modules/ncc-spoke-ra"
name = "prod-spoke-untrusted-${local.region_shortnames[each.value]}"
name = "prod-spoke-dmz-${local.region_shortnames[each.value]}"
project_id = module.landing-project.project_id
region = each.value
hub = {
create = false,
id = google_network_connectivity_hub.hub_untrusted.id
id = google_network_connectivity_hub.hub_dmz.id
}
router_appliances = [
@ -97,9 +101,13 @@ module "spokes-untrusted" {
]
router_config = {
asn = var.ncc_asn.untrusted
ip_interface0 = cidrhost(module.landing-untrusted-vpc.subnet_ips["${each.value}/landing-untrusted-default-${local.region_shortnames[each.value]}"], 201)
ip_interface1 = cidrhost(module.landing-untrusted-vpc.subnet_ips["${each.value}/landing-untrusted-default-${local.region_shortnames[each.value]}"], 202)
asn = var.ncc_asn.dmz
ip_interface0 = cidrhost(
module.dmz-vpc.subnet_ips["${each.value}/dmz-default"], 201
)
ip_interface1 = cidrhost(
module.dmz-vpc.subnet_ips["${each.value}/dmz-default"], 202
)
peer_asn = (
each.key == "primary"
? var.ncc_asn.nva_primary
@ -114,7 +122,7 @@ module "spokes-untrusted" {
}
vpc_config = {
network_name = module.landing-untrusted-vpc.self_link
subnet_self_link = module.landing-untrusted-vpc.subnet_self_links["${each.value}/landing-untrusted-default-${local.region_shortnames[each.value]}"]
network_name = module.dmz-vpc.self_link
subnet_self_link = module.dmz-vpc.subnet_self_links["${each.value}/dmz-default"]
}
}

View File

@ -101,5 +101,5 @@ module "peering-dev" {
source = "../../../modules/net-vpc-peering"
prefix = "dev-peering-0"
local_network = module.dev-spoke-vpc.self_link
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}

View File

@ -43,12 +43,12 @@ module "landing-project" {
}
}
# Untrusted VPC
# DMZ (untrusted) VPC
module "landing-untrusted-vpc" {
module "dmz-vpc" {
source = "../../../modules/net-vpc"
project_id = module.landing-project.project_id
name = "prod-untrusted-landing-0"
name = "prod-dmz-0"
mtu = 1500
dns_policy = {
inbound = true
@ -56,30 +56,25 @@ module "landing-untrusted-vpc" {
}
create_googleapis_routes = null
factories_config = {
subnets_folder = "${var.factories_config.data_dir}/subnets/landing-untrusted"
subnets_folder = "${var.factories_config.data_dir}/subnets/dmz"
}
}
module "landing-untrusted-firewall" {
module "dmz-firewall" {
source = "../../../modules/net-vpc-firewall"
project_id = module.landing-project.project_id
network = module.landing-untrusted-vpc.name
network = module.dmz-vpc.name
default_rules_config = {
disabled = true
}
factories_config = {
cidr_tpl_file = "${var.factories_config.data_dir}/cidrs.yaml"
rules_folder = "${var.factories_config.data_dir}/firewall-rules/landing-untrusted"
rules_folder = "${var.factories_config.data_dir}/firewall-rules/dmz"
}
}
# NAT
moved {
from = module.landing-nat-ew1
to = module.landing-nat-primary
}
module "landing-nat-primary" {
source = "../../../modules/net-cloudnat"
count = var.enable_cloud_nat ? 1 : 0
@ -88,12 +83,7 @@ module "landing-nat-primary" {
name = local.region_shortnames[var.regions.primary]
router_create = true
router_name = "prod-nat-${local.region_shortnames[var.regions.primary]}"
router_network = module.landing-untrusted-vpc.name
}
moved {
from = module.landing-nat-ew4
to = module.landing-nat-secondary
router_network = module.dmz-vpc.name
}
module "landing-nat-secondary" {
@ -104,19 +94,19 @@ module "landing-nat-secondary" {
name = local.region_shortnames[var.regions.secondary]
router_create = true
router_name = "prod-nat-${local.region_shortnames[var.regions.secondary]}"
router_network = module.landing-untrusted-vpc.name
router_network = module.dmz-vpc.name
}
# Trusted VPC
# landing (trusted) VPC
module "landing-trusted-vpc" {
module "landing-vpc" {
source = "../../../modules/net-vpc"
project_id = module.landing-project.project_id
name = "prod-trusted-landing-0"
name = "prod-landing-0"
delete_default_routes_on_create = true
mtu = 1500
factories_config = {
subnets_folder = "${var.factories_config.data_dir}/subnets/landing-trusted"
subnets_folder = "${var.factories_config.data_dir}/subnets/landing"
}
dns_policy = {
inbound = true
@ -128,15 +118,15 @@ module "landing-trusted-vpc" {
}
}
module "landing-trusted-firewall" {
module "landing-firewall" {
source = "../../../modules/net-vpc-firewall"
project_id = module.landing-project.project_id
network = module.landing-trusted-vpc.name
network = module.landing-vpc.name
default_rules_config = {
disabled = true
}
factories_config = {
cidr_tpl_file = "${var.factories_config.data_dir}/cidrs.yaml"
rules_folder = "${var.factories_config.data_dir}/firewall-rules/landing-trusted"
rules_folder = "${var.factories_config.data_dir}/firewall-rules/landing"
}
}

View File

@ -99,5 +99,5 @@ module "peering-prod" {
source = "../../../modules/net-vpc-peering"
prefix = "prod-peering-0"
local_network = module.prod-spoke-vpc.self_link
peer_network = module.landing-trusted-vpc.self_link
peer_network = module.landing-vpc.self_link
}

View File

@ -18,7 +18,7 @@ locals {
_nva_zones = ["b", "c"]
# The configurations used to create the NVA VMs.
#
#
# Rendered as following:
# nva_configs = {
# primary-b = {...}
@ -43,33 +43,51 @@ locals {
? var.ncc_asn.nva_secondary
: var.ncc_asn.nva_primary
)
asn_trusted = var.ncc_asn.trusted
asn_untrusted = var.ncc_asn.untrusted
asn_landing = var.ncc_asn.landing
asn_dmz = var.ncc_asn.dmz
# To guarantee traffic to remain symmetric,
# NVAs need to advertise cross-region routes with a higher cost (10100)
cost_primary = v.0 == "primary" ? "100" : "10100"
cost_secondary = v.0 == "primary" ? "10100" : "100"
gcp_dev_primary = var.gcp_ranges.gcp_dev_primary
gcp_dev_secondary = var.gcp_ranges.gcp_dev_secondary
gcp_landing_trusted_primary = var.gcp_ranges.gcp_landing_trusted_primary
gcp_landing_trusted_secondary = var.gcp_ranges.gcp_landing_trusted_secondary
gcp_landing_untrusted_primary = var.gcp_ranges.gcp_landing_untrusted_primary
gcp_landing_untrusted_secondary = var.gcp_ranges.gcp_landing_untrusted_secondary
gcp_prod_primary = var.gcp_ranges.gcp_prod_primary
gcp_prod_secondary = var.gcp_ranges.gcp_prod_secondary
# The IPs of cross-region NVA VMs in the untrusted VPC (x.y.w.z)
ip_neighbor_cross_region_nva_0 = cidrhost(module.landing-untrusted-vpc.subnet_ips["${local._regions_cross[v.0]}/landing-untrusted-default-${local.region_shortnames[local._regions_cross[v.0]]}"], 101)
ip_neighbor_cross_region_nva_1 = cidrhost(module.landing-untrusted-vpc.subnet_ips["${local._regions_cross[v.0]}/landing-untrusted-default-${local.region_shortnames[local._regions_cross[v.0]]}"], 102)
# The Cloud router IPs (x.y.w.z) in the untrusted
# and in the trusted VPCs, where the NVA connects to
ip_neighbor_trusted_0 = cidrhost(module.landing-trusted-vpc.subnet_ips["${var.regions[v.0]}/landing-trusted-default-${local.region_shortnames[var.regions[v.0]]}"], 201)
ip_neighbor_trusted_1 = cidrhost(module.landing-trusted-vpc.subnet_ips["${var.regions[v.0]}/landing-trusted-default-${local.region_shortnames[var.regions[v.0]]}"], 202)
ip_neighbor_untrusted_0 = cidrhost(module.landing-untrusted-vpc.subnet_ips["${var.regions[v.0]}/landing-untrusted-default-${local.region_shortnames[var.regions[v.0]]}"], 201)
ip_neighbor_untrusted_1 = cidrhost(module.landing-untrusted-vpc.subnet_ips["${var.regions[v.0]}/landing-untrusted-default-${local.region_shortnames[var.regions[v.0]]}"], 202)
cost_primary = v.0 == "primary" ? "100" : "10100"
cost_secondary = v.0 == "primary" ? "10100" : "100"
gcp_dev_primary = var.gcp_ranges.gcp_dev_primary
gcp_dev_secondary = var.gcp_ranges.gcp_dev_secondary
gcp_landing_landing_primary = var.gcp_ranges.gcp_landing_primary
gcp_landing_landing_secondary = var.gcp_ranges.gcp_landing_secondary
gcp_landing_dmz_primary = var.gcp_ranges.gcp_dmz_primary
gcp_landing_dmz_secondary = var.gcp_ranges.gcp_dmz_secondary
gcp_prod_primary = var.gcp_ranges.gcp_prod_primary
gcp_prod_secondary = var.gcp_ranges.gcp_prod_secondary
# The IPs of cross-region NVA VMs in the DMZ VPC (x.y.w.z)
ip_neighbor_cross_region_nva_0 = cidrhost(
module.dmz-vpc.subnet_ips["${local._regions_cross[v.0]}/dmz-default"], 101
)
ip_neighbor_cross_region_nva_1 = cidrhost(
module.dmz-vpc.subnet_ips["${local._regions_cross[v.0]}/dmz-default"], 102
)
# The Cloud router IPs (x.y.w.z) in the DMZ
# and in the landing VPCs, where the NVA connects to
ip_neighbor_landing_0 = cidrhost(
module.landing-vpc.subnet_ips["${var.regions[v.0]}/landing-default"], 201
)
ip_neighbor_landing_1 = cidrhost(
module.landing-vpc.subnet_ips["${var.regions[v.0]}/landing-default"], 202
)
ip_neighbor_dmz_0 = cidrhost(
module.dmz-vpc.subnet_ips["${var.regions[v.0]}/dmz-default"], 201
)
ip_neighbor_dmz_1 = cidrhost(
module.dmz-vpc.subnet_ips["${var.regions[v.0]}/dmz-default"], 202
)
# The IPs to assign to the NVA NICs
# in the trusted and in the untrusted VPCs.
ip_trusted = cidrhost(module.landing-trusted-vpc.subnet_ips["${var.regions[v.0]}/landing-trusted-default-${local.region_shortnames[var.regions[v.0]]}"], 101 + index(var.zones, v.1))
ip_untrusted = cidrhost(module.landing-untrusted-vpc.subnet_ips["${var.regions[v.0]}/landing-untrusted-default-${local.region_shortnames[var.regions[v.0]]}"], 101 + index(var.zones, v.1))
# in the landing and in the DMZ VPCs.
ip_landing = cidrhost(
module.landing-vpc.subnet_ips["${var.regions[v.0]}/landing-default"],
101 + index(var.zones, v.1)
)
ip_dmz = cidrhost(
module.dmz-vpc.subnet_ips["${var.regions[v.0]}/dmz-default"],
101 + index(var.zones, v.1)
)
# Either primary or secondary
name = v.0
# The name of the region where the NVA lives.
@ -89,17 +107,17 @@ locals {
routing_config = [
{
enable_masquerading = true
name = "untrusted"
name = "dmz"
routes = [
var.gcp_ranges.gcp_landing_untrusted_primary,
var.gcp_ranges.gcp_landing_untrusted_secondary
var.gcp_ranges.gcp_dmz_primary,
var.gcp_ranges.gcp_dmz_secondary
]
},
{
name = "trusted"
name = "landing"
routes = [
var.gcp_ranges.gcp_landing_trusted_primary,
var.gcp_ranges.gcp_landing_trusted_secondary
var.gcp_ranges.gcp_landing_primary,
var.gcp_ranges.gcp_landing_secondary
]
}
]
@ -116,23 +134,25 @@ module "nva-bgp-cloud-config" {
}
}
resource "google_compute_address" "nva_static_ip_trusted" {
# TODO: use address module
resource "google_compute_address" "nva_static_ip_landing" {
for_each = local.nva_configs
name = "nva-ip-trusted-${each.value.shortname}-${each.value.zone}"
name = "nva-ip-landing-${each.value.shortname}-${each.value.zone}"
project = module.landing-project.project_id
subnetwork = module.landing-trusted-vpc.subnet_self_links["${each.value.region}/landing-trusted-default-${each.value.shortname}"]
subnetwork = module.landing-vpc.subnet_self_links["${each.value.region}/landing-default"]
address_type = "INTERNAL"
address = each.value.ip_trusted
address = each.value.ip_landing
region = each.value.region
}
resource "google_compute_address" "nva_static_ip_untrusted" {
resource "google_compute_address" "nva_static_ip_dmz" {
for_each = local.nva_configs
name = "nva-ip-untrusted-${each.value.shortname}-${each.value.zone}"
name = "nva-ip-dmz-${each.value.shortname}-${each.value.zone}"
project = module.landing-project.project_id
subnetwork = module.landing-untrusted-vpc.subnet_self_links["${each.value.region}/landing-untrusted-default-${each.value.shortname}"]
subnetwork = module.dmz-vpc.subnet_self_links["${each.value.region}/dmz-default"]
address_type = "INTERNAL"
address = each.value.ip_untrusted
address = each.value.ip_dmz
region = each.value.region
}
@ -148,19 +168,19 @@ module "nva" {
network_interfaces = [
{
network = module.landing-untrusted-vpc.self_link
subnetwork = module.landing-untrusted-vpc.subnet_self_links["${each.value.region}/landing-untrusted-default-${each.value.shortname}"]
network = module.dmz-vpc.self_link
subnetwork = module.dmz-vpc.subnet_self_links["${each.value.region}/dmz-default"]
nat = false
addresses = {
internal = google_compute_address.nva_static_ip_untrusted[each.key].address
internal = google_compute_address.nva_static_ip_dmz[each.key].address
}
},
{
network = module.landing-trusted-vpc.self_link
subnetwork = module.landing-trusted-vpc.subnet_self_links["${each.value.region}/landing-trusted-default-${each.value.shortname}"]
network = module.landing-vpc.self_link
subnetwork = module.landing-vpc.subnet_self_links["${each.value.region}/landing-default"]
nat = false
addresses = {
internal = google_compute_address.nva_static_ip_trusted[each.key].address
internal = google_compute_address.nva_static_ip_landing[each.key].address
}
}
]

View File

@ -31,10 +31,10 @@ locals {
vpc_self_links = local.vpc_self_links
}
vpc_self_links = {
prod-landing-trusted = module.landing-trusted-vpc.self_link
prod-landing-untrusted = module.landing-untrusted-vpc.self_link
dev-spoke-0 = module.dev-spoke-vpc.self_link
prod-spoke-0 = module.prod-spoke-vpc.self_link
prod-landing = module.landing-vpc.self_link
prod-dmz = module.dmz-vpc.self_link
dev-spoke-0 = module.dev-spoke-vpc.self_link
prod-spoke-0 = module.prod-spoke-vpc.self_link
}
}

View File

@ -16,16 +16,14 @@
# tfdoc:file:description temporary instances for testing
# # Untrusted (Landing)
# module "test-vm-landing-untrusted-primary-0" {
# module "test-vm-dmz-primary-0" {
# source = "../../../modules/compute-vm"
# project_id = module.landing-project.project_id
# zone = "${var.regions.primary}-b"
# name = "test-vm-lnd-unt-primary-0"
# network_interfaces = [{
# network = module.landing-untrusted-vpc.self_link
# subnetwork = module.landing-untrusted-vpc.subnet_self_links["${var.regions.primary}/landing-untrusted-default-${local.region_shortnames[var.regions.primary]}"]
# network = module.dmz-vpc.self_link
# subnetwork = module.dmz-vpc.subnet_self_links["${var.regions.primary}/dmz-default-${local.region_shortnames[var.regions.primary]}"]
# }]
# tags = ["primary", "ssh"]
# boot_disk = {
@ -45,14 +43,14 @@
# }
# }
# module "test-vm-landing-untrusted-secondary-0" {
# module "test-vm-dmz-secondary-0" {
# source = "../../../modules/compute-vm"
# project_id = module.landing-project.project_id
# zone = "${var.regions.secondary}-a"
# name = "test-vm-lnd-unt-secondary-0"
# network_interfaces = [{
# network = module.landing-untrusted-vpc.self_link
# subnetwork = module.landing-untrusted-vpc.subnet_self_links["${var.regions.secondary}/landing-untrusted-default-${local.region_shortnames[var.regions.secondary]}"]
# network = module.dmz-vpc.self_link
# subnetwork = module.dmz-vpc.subnet_self_links["${var.regions.secondary}/dmz-default-${local.region_shortnames[var.regions.secondary]}"]
# }]
# tags = ["secondary", "ssh"]
# boot_disk = {
@ -72,16 +70,16 @@
# }
# }
# # Trusted (hub)
# # Landing (hub)
# module "test-vm-landing-trusted-primary-0" {
# module "test-vm-landing-primary-0" {
# source = "../../../modules/compute-vm"
# project_id = module.landing-project.project_id
# zone = "${var.regions.primary}-b"
# name = "test-vm-lnd-tru-primary-0"
# network_interfaces = [{
# network = module.landing-trusted-vpc.self_link
# subnetwork = module.landing-trusted-vpc.subnet_self_links["${var.regions.primary}/landing-trusted-default-${local.region_shortnames[var.regions.primary]}"]
# network = module.landing-vpc.self_link
# subnetwork = module.landing-vpc.subnet_self_links["${var.regions.primary}/landing-default"]
# }]
# tags = ["primary", "ssh"]
# boot_disk = {
@ -101,14 +99,14 @@
# }
# }
# module "test-vm-landing-trusted-secondary-0" {
# module "test-vm-landing-secondary-0" {
# source = "../../../modules/compute-vm"
# project_id = module.landing-project.project_id
# zone = "${var.regions.secondary}-a"
# name = "test-vm-lnd-tru-secondary-0"
# network_interfaces = [{
# network = module.landing-trusted-vpc.self_link
# subnetwork = module.landing-trusted-vpc.subnet_self_links["${var.regions.secondary}/landing-trusted-default-${local.region_shortnames[var.regions.secondary]}"]
# network = module.landing-vpc.self_link
# subnetwork = module.landing-vpc.subnet_self_links["${var.regions.secondary}/landing-default"]
# }]
# tags = ["secondary", "ssh"]
# boot_disk = {
@ -138,7 +136,7 @@
# network_interfaces = [{
# network = module.dev-spoke-vpc.self_link
# # change the subnet name to match the values you are actually using
# subnetwork = module.dev-spoke-vpc.subnet_self_links["${var.regions.primary}/dev-default-${local.region_shortnames[var.regions.primary]}"]
# subnetwork = module.dev-spoke-vpc.subnet_self_links["${var.regions.primary}/dev-default"]
# }]
# tags = ["primary", "ssh"]
# boot_disk = {
@ -166,7 +164,7 @@
# network_interfaces = [{
# network = module.dev-spoke-vpc.self_link
# # change the subnet name to match the values you are actually using
# subnetwork = module.dev-spoke-vpc.subnet_self_links["${var.regions.secondary}/dev-default-${local.region_shortnames[var.regions.secondary]}"]
# subnetwork = module.dev-spoke-vpc.subnet_self_links["${var.regions.secondary}/dev-default"]
# }]
# tags = ["secondary", "ssh"]
# boot_disk = {
@ -196,7 +194,7 @@
# network_interfaces = [{
# network = module.prod-spoke-vpc.self_link
# # change the subnet name to match the values you are actually using
# subnetwork = module.prod-spoke-vpc.subnet_self_links["${var.regions.primary}/prod-default-${local.region_shortnames[var.regions.primary]}"]
# subnetwork = module.prod-spoke-vpc.subnet_self_links["${var.regions.primary}/prod-default"]
# }]
# tags = ["primary", "ssh"]
# boot_disk = {
@ -224,7 +222,7 @@
# network_interfaces = [{
# network = module.prod-spoke-vpc.self_link
# # change the subnet name to match the values you are actually using
# subnetwork = module.prod-spoke-vpc.subnet_self_links["${var.regions.secondary}/prod-default-${local.region_shortnames[var.regions.secondary]}"]
# subnetwork = module.prod-spoke-vpc.subnet_self_links["${var.regions.secondary}/prod-default"]
# }]
# tags = ["secondary", "ssh"]
# boot_disk = {

View File

@ -127,14 +127,14 @@ variable "gcp_ranges" {
description = "GCP address ranges in name => range format."
type = map(string)
default = {
gcp_dev_primary = "10.68.0.0/16"
gcp_dev_secondary = "10.84.0.0/16"
gcp_landing_trusted_primary = "10.64.0.0/17"
gcp_landing_trusted_secondary = "10.80.0.0/17"
gcp_landing_untrusted_primary = "10.64.127.0/17"
gcp_landing_untrusted_secondary = "10.80.127.0/17"
gcp_prod_primary = "10.72.0.0/16"
gcp_prod_secondary = "10.88.0.0/16"
gcp_dev_primary = "10.68.0.0/16"
gcp_dev_secondary = "10.84.0.0/16"
gcp_landing_primary = "10.64.0.0/17"
gcp_landing_secondary = "10.80.0.0/17"
gcp_dmz_primary = "10.64.127.0/17"
gcp_dmz_secondary = "10.80.127.0/17"
gcp_prod_primary = "10.72.0.0/16"
gcp_prod_secondary = "10.88.0.0/16"
}
}
@ -144,8 +144,8 @@ variable "ncc_asn" {
default = {
nva_primary = 64513
nva_secondary = 64514
trusted = 64515
untrusted = 64512
landing = 64515
dmz = 64512
}
}

View File

@ -31,7 +31,7 @@ module "landing-to-onprem-primary-vpn" {
count = var.vpn_onprem_primary_config == null ? 0 : 1
source = "../../../modules/net-vpn-ha"
project_id = module.landing-project.project_id
network = module.landing-trusted-vpc.self_link
network = module.landing-vpc.self_link
region = var.regions.primary
name = "vpn-to-onprem-${local.region_shortnames[var.regions.primary]}"
router_config = try(var.vpn_onprem_primary_config.router_config, {})
@ -45,7 +45,7 @@ module "landing-to-onprem-secondary-vpn" {
count = var.vpn_onprem_secondary_config == null ? 0 : 1
source = "../../../modules/net-vpn-ha"
project_id = module.landing-project.project_id
network = module.landing-trusted-vpc.self_link
network = module.landing-vpc.self_link
region = var.regions.secondary
name = "vpn-to-onprem-${local.region_shortnames[var.regions.secondary]}"
router_config = try(var.vpn_onprem_secondary_config.router_config, {})

View File

@ -13,5 +13,44 @@
# limitations under the License.
counts:
google_compute_external_vpn_gateway: 2
google_compute_firewall: 9
google_compute_firewall_policy: 1
google_compute_firewall_policy_association: 1
google_compute_firewall_policy_rule: 4
google_compute_forwarding_rule: 4
google_compute_ha_vpn_gateway: 2
google_compute_health_check: 8
google_compute_instance_template: 4
google_compute_network: 6
google_compute_network_peering: 4
google_compute_region_backend_service: 4
google_compute_region_instance_group_manager: 4
google_compute_route: 14
google_compute_router: 4
google_compute_router_interface: 4
google_compute_router_nat: 2
google_compute_router_peer: 4
google_compute_shared_vpc_host_project: 3
google_compute_subnetwork: 12
google_compute_vpn_tunnel: 4
google_dns_managed_zone: 9
google_dns_policy: 4
google_dns_record_set: 3
google_dns_response_policy: 1
google_dns_response_policy_rule: 34
google_essential_contacts_contact: 1
google_folder: 1
google_monitoring_alert_policy: 2
google_monitoring_dashboard: 3
google_monitoring_monitored_project: 2
google_project: 3
google_project_iam_binding: 6
google_project_iam_member: 2
google_project_service: 21
google_project_service_identity: 5
google_storage_bucket_object: 2
google_vpc_access_connector: 2
modules: 43
resources: 201
random_id: 2
resources: 203

File diff suppressed because it is too large Load Diff