cloud-foundation-fabric/fast/stages/2-networking-c-nva/net-landing.tf

132 lines
3.9 KiB
Terraform
Raw Normal View History

2022-02-03 11:30:56 -08:00
/**
* Copyright 2024 Google LLC
2022-02-03 11:30:56 -08:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
# tfdoc:file:description Landing VPC and related resources.
module "landing-project" {
source = "../../../modules/project"
2022-02-15 23:07:58 -08:00
billing_account = var.billing_account.id
2022-02-03 11:30:56 -08:00
name = "prod-net-landing-0"
parent = var.folder_ids.networking-prod
2022-02-03 11:30:56 -08:00
prefix = var.prefix
services = [
"compute.googleapis.com",
"dns.googleapis.com",
"iap.googleapis.com",
"networkmanagement.googleapis.com",
"stackdriver.googleapis.com"
]
shared_vpc_host_config = {
enabled = true
2022-02-03 11:30:56 -08:00
}
2022-02-15 23:07:58 -08:00
iam = {
2022-07-05 00:46:53 -07:00
"roles/dns.admin" = compact([
try(local.service_accounts.project-factory-prod, null)
])
(local.custom_roles.service_project_network_admin) = compact([
try(local.service_accounts.project-factory-prod, null)
])
2022-02-15 23:07:58 -08:00
}
2022-02-03 11:30:56 -08:00
}
# DMZ (untrusted) VPC
2022-02-03 11:30:56 -08:00
module "dmz-vpc" {
2022-02-03 11:30:56 -08:00
source = "../../../modules/net-vpc"
project_id = module.landing-project.project_id
name = "prod-dmz-0"
2022-02-03 11:30:56 -08:00
mtu = 1500
dns_policy = {
inbound = true
logging = var.dns.enable_logging
2022-02-03 11:30:56 -08:00
}
create_googleapis_routes = null
2023-09-14 15:07:08 -07:00
factories_config = {
subnets_folder = "${var.factories_config.data_dir}/subnets/dmz"
2023-09-14 15:07:08 -07:00
}
2022-02-03 11:30:56 -08:00
}
module "dmz-firewall" {
source = "../../../modules/net-vpc-firewall"
project_id = module.landing-project.project_id
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/dmz"
}
2022-02-03 11:30:56 -08:00
}
# NAT
module "dmz-nat-primary" {
2022-02-03 11:30:56 -08:00
source = "../../../modules/net-cloudnat"
count = var.enable_cloud_nat ? 1 : 0
2022-02-03 11:30:56 -08:00
project_id = module.landing-project.project_id
region = var.regions.primary
name = local.region_shortnames[var.regions.primary]
2022-02-03 11:30:56 -08:00
router_create = true
router_name = "prod-nat-${local.region_shortnames[var.regions.primary]}"
router_network = module.dmz-vpc.name
}
module "dmz-nat-secondary" {
2022-02-03 11:30:56 -08:00
source = "../../../modules/net-cloudnat"
count = var.enable_cloud_nat ? 1 : 0
2022-02-03 11:30:56 -08:00
project_id = module.landing-project.project_id
region = var.regions.secondary
name = local.region_shortnames[var.regions.secondary]
2022-02-03 11:30:56 -08:00
router_create = true
router_name = "prod-nat-${local.region_shortnames[var.regions.secondary]}"
router_network = module.dmz-vpc.name
2022-02-03 11:30:56 -08:00
}
# Landing (trusted) VPC
2022-02-03 11:30:56 -08:00
module "landing-vpc" {
2022-02-03 11:30:56 -08:00
source = "../../../modules/net-vpc"
project_id = module.landing-project.project_id
name = "prod-landing-0"
2022-02-03 11:30:56 -08:00
delete_default_routes_on_create = true
mtu = 1500
2023-09-14 15:07:08 -07:00
factories_config = {
subnets_folder = "${var.factories_config.data_dir}/subnets/landing"
2023-09-14 15:07:08 -07:00
}
dns_policy = {
inbound = true
}
2022-02-03 11:30:56 -08:00
# Set explicit routes for googleapis in case the default route is deleted
2023-05-26 07:43:43 -07:00
create_googleapis_routes = {
private = true
restricted = true
2022-02-03 11:30:56 -08:00
}
}
module "landing-firewall" {
source = "../../../modules/net-vpc-firewall"
project_id = module.landing-project.project_id
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"
}
2022-02-03 11:30:56 -08:00
}