2022-01-01 06:52:31 -08:00
|
|
|
# Copyright 2022 Google LLC
|
2021-07-26 00:22:40 -07: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
|
|
|
|
#
|
|
|
|
# https://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.
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Shared VPC Host projects #
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
module "project-host-prod" {
|
2022-01-10 06:09:38 -08:00
|
|
|
source = "../../../modules/project"
|
2021-07-26 00:22:40 -07:00
|
|
|
parent = var.root_node
|
|
|
|
billing_account = var.billing_account_id
|
|
|
|
prefix = var.prefix
|
|
|
|
name = "prod-host"
|
|
|
|
services = var.project_services
|
|
|
|
|
|
|
|
shared_vpc_host_config = {
|
2022-10-06 23:55:47 -07:00
|
|
|
enabled = true
|
2021-07-26 00:22:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module "project-host-dev" {
|
2022-01-10 06:09:38 -08:00
|
|
|
source = "../../../modules/project"
|
2021-07-26 00:22:40 -07:00
|
|
|
parent = var.root_node
|
|
|
|
billing_account = var.billing_account_id
|
|
|
|
prefix = var.prefix
|
|
|
|
name = "dev-host"
|
|
|
|
services = var.project_services
|
|
|
|
|
|
|
|
shared_vpc_host_config = {
|
2022-10-06 23:55:47 -07:00
|
|
|
enabled = true
|
2021-07-26 00:22:40 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Networking #
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
module "vpc-prod" {
|
2022-01-10 06:09:38 -08:00
|
|
|
source = "../../../modules/net-vpc"
|
2021-07-26 00:22:40 -07:00
|
|
|
project_id = module.project-host-prod.project_id
|
|
|
|
name = "prod-vpc"
|
|
|
|
subnets = [
|
|
|
|
{
|
2022-10-14 02:02:33 -07:00
|
|
|
ip_cidr_range = var.ip_ranges.prod
|
|
|
|
name = "prod"
|
|
|
|
region = var.region
|
2021-07-26 00:22:40 -07:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
module "vpc-dev" {
|
2022-01-10 06:09:38 -08:00
|
|
|
source = "../../../modules/net-vpc"
|
2021-07-26 00:22:40 -07:00
|
|
|
project_id = module.project-host-dev.project_id
|
|
|
|
name = "dev-vpc"
|
|
|
|
subnets = [
|
|
|
|
{
|
2022-10-14 02:02:33 -07:00
|
|
|
ip_cidr_range = var.ip_ranges.dev
|
|
|
|
name = "dev"
|
|
|
|
region = var.region
|
2021-07-26 00:22:40 -07:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Private Google Access DNS #
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
module "dns-api-prod" {
|
2022-01-10 06:09:38 -08:00
|
|
|
source = "../../../modules/dns"
|
2021-07-26 00:22:40 -07:00
|
|
|
project_id = module.project-host-prod.project_id
|
|
|
|
type = "private"
|
|
|
|
name = "googleapis"
|
|
|
|
domain = "googleapis.com."
|
|
|
|
client_networks = [module.vpc-prod.self_link]
|
2021-10-04 09:59:14 -07:00
|
|
|
recordsets = {
|
2022-10-25 03:04:14 -07:00
|
|
|
"CNAME *" = { records = ["private.googleapis.com."] }
|
2021-10-04 09:59:14 -07:00
|
|
|
}
|
2021-07-26 00:22:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
module "dns-api-dev" {
|
2022-01-10 06:09:38 -08:00
|
|
|
source = "../../../modules/dns"
|
2021-07-26 00:22:40 -07:00
|
|
|
project_id = module.project-host-dev.project_id
|
|
|
|
type = "private"
|
|
|
|
name = "googleapis"
|
|
|
|
domain = "googleapis.com."
|
|
|
|
client_networks = [module.vpc-dev.self_link]
|
2021-10-04 09:59:14 -07:00
|
|
|
recordsets = {
|
2022-10-25 03:04:14 -07:00
|
|
|
"CNAME *" = { records = ["private.googleapis.com."] }
|
2021-10-04 09:59:14 -07:00
|
|
|
}
|
2021-07-26 00:22:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Distributed Firewall #
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
module "vpc-firewall-prod" {
|
2022-01-13 23:30:06 -08:00
|
|
|
source = "../../factories/net-vpc-firewall-yaml"
|
2021-07-26 00:22:40 -07:00
|
|
|
|
|
|
|
project_id = module.project-host-prod.project_id
|
|
|
|
network = module.vpc-prod.name
|
|
|
|
config_directories = [
|
2021-07-28 13:14:14 -07:00
|
|
|
"${path.module}/firewall/common",
|
|
|
|
"${path.module}/firewall/prod"
|
2021-07-26 00:22:40 -07:00
|
|
|
]
|
|
|
|
|
|
|
|
# Enable Firewall Logging for the production fwl rules
|
|
|
|
log_config = {
|
|
|
|
metadata = "INCLUDE_ALL_METADATA"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module "vpc-firewall-dev" {
|
2022-01-13 23:30:06 -08:00
|
|
|
source = "../../factories/net-vpc-firewall-yaml"
|
2021-07-26 00:22:40 -07:00
|
|
|
|
|
|
|
project_id = module.project-host-dev.project_id
|
|
|
|
network = module.vpc-dev.name
|
|
|
|
config_directories = [
|
2021-07-28 13:14:14 -07:00
|
|
|
"${path.module}/firewall/common",
|
|
|
|
"${path.module}/firewall/dev"
|
2021-07-26 00:22:40 -07:00
|
|
|
]
|
|
|
|
}
|