2022-01-17 23:58:14 -08:00
|
|
|
# Copyright 2022 Google LLC
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2022-02-01 00:30:29 -08:00
|
|
|
# tfdoc:file:description Orchestration project and VPC.
|
2022-01-31 21:41:33 -08:00
|
|
|
|
2022-01-17 23:58:14 -08:00
|
|
|
locals {
|
2022-02-09 08:01:25 -08:00
|
|
|
orch_subnet = (
|
|
|
|
local.use_shared_vpc
|
|
|
|
? var.network_config.subnet_self_links.orchestration
|
|
|
|
: values(module.orch-vpc.0.subnet_self_links)[0]
|
|
|
|
)
|
|
|
|
orch_vpc = (
|
|
|
|
local.use_shared_vpc
|
|
|
|
? var.network_config.network_self_link
|
|
|
|
: module.orch-vpc.0.self_link
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
module "orch-project" {
|
|
|
|
source = "../../../modules/project"
|
|
|
|
parent = var.folder_id
|
|
|
|
billing_account = var.billing_account_id
|
|
|
|
prefix = var.prefix
|
|
|
|
name = "orc"
|
|
|
|
group_iam = {
|
|
|
|
(local.groups.data-engineers) = [
|
2022-01-31 09:58:55 -08:00
|
|
|
"roles/bigquery.dataEditor",
|
|
|
|
"roles/bigquery.jobUser",
|
|
|
|
"roles/cloudbuild.builds.editor",
|
|
|
|
"roles/composer.admin",
|
|
|
|
"roles/composer.environmentAndStorageObjectAdmin",
|
|
|
|
"roles/iap.httpsResourceAccessor",
|
|
|
|
"roles/iam.serviceAccountUser",
|
|
|
|
"roles/compute.networkUser",
|
|
|
|
"roles/storage.objectAdmin",
|
|
|
|
"roles/storage.admin",
|
|
|
|
"roles/compute.networkUser"
|
|
|
|
]
|
|
|
|
}
|
2022-02-09 08:01:25 -08:00
|
|
|
iam = {
|
2022-01-17 23:58:14 -08:00
|
|
|
"roles/bigquery.dataEditor" = [
|
2022-02-09 08:01:25 -08:00
|
|
|
module.load-sa-df-0.iam_email,
|
|
|
|
module.transf-sa-df-0.iam_email,
|
|
|
|
module.orch-sa-cmp-0.iam_email,
|
2022-01-17 23:58:14 -08:00
|
|
|
]
|
|
|
|
"roles/bigquery.jobUser" = [
|
2022-02-09 08:01:25 -08:00
|
|
|
module.load-sa-df-0.iam_email,
|
|
|
|
module.transf-sa-df-0.iam_email,
|
|
|
|
module.orch-sa-cmp-0.iam_email,
|
2022-01-17 23:58:14 -08:00
|
|
|
]
|
|
|
|
"roles/composer.worker" = [
|
2022-02-09 08:01:25 -08:00
|
|
|
module.orch-sa-cmp-0.iam_email
|
2022-01-17 23:58:14 -08:00
|
|
|
]
|
2022-01-18 15:53:52 -08:00
|
|
|
"roles/iam.serviceAccountUser" = [
|
2022-02-09 08:01:25 -08:00
|
|
|
module.orch-sa-cmp-0.iam_email
|
2022-01-18 15:53:52 -08:00
|
|
|
]
|
2022-01-17 23:58:14 -08:00
|
|
|
"roles/storage.objectAdmin" = [
|
2022-02-09 08:01:25 -08:00
|
|
|
module.load-sa-df-0.iam_email,
|
|
|
|
module.orch-sa-cmp-0.iam_email,
|
|
|
|
"serviceAccount:${module.orch-project.service_accounts.robots.composer}",
|
2022-01-17 23:58:14 -08:00
|
|
|
]
|
|
|
|
"roles/storage.admin" = [
|
2022-02-09 08:01:25 -08:00
|
|
|
module.load-sa-df-0.iam_email,
|
|
|
|
module.transf-sa-df-0.iam_email
|
2022-01-17 23:58:14 -08:00
|
|
|
]
|
|
|
|
}
|
2022-02-09 08:01:25 -08:00
|
|
|
oslogin = false
|
2022-02-07 12:28:54 -08:00
|
|
|
policy_boolean = {
|
|
|
|
"constraints/compute.requireOsLogin" = false
|
|
|
|
}
|
2022-02-09 08:01:25 -08:00
|
|
|
services = concat(var.project_services, [
|
|
|
|
"artifactregistry.googleapis.com",
|
|
|
|
"bigquery.googleapis.com",
|
|
|
|
"bigqueryreservation.googleapis.com",
|
|
|
|
"bigquerystorage.googleapis.com",
|
|
|
|
"cloudbuild.googleapis.com",
|
|
|
|
"cloudkms.googleapis.com",
|
|
|
|
"composer.googleapis.com",
|
|
|
|
"compute.googleapis.com",
|
|
|
|
"container.googleapis.com",
|
|
|
|
"containerregistry.googleapis.com",
|
|
|
|
"dataflow.googleapis.com",
|
|
|
|
"pubsub.googleapis.com",
|
|
|
|
"servicenetworking.googleapis.com",
|
|
|
|
"storage.googleapis.com",
|
|
|
|
"storage-component.googleapis.com"
|
2022-01-17 23:58:14 -08:00
|
|
|
])
|
2022-01-19 12:33:24 -08:00
|
|
|
service_encryption_key_ids = {
|
2022-01-31 08:11:06 -08:00
|
|
|
composer = [try(local.service_encryption_keys.composer, null)]
|
|
|
|
storage = [try(local.service_encryption_keys.storage, null)]
|
2022-01-19 12:33:24 -08:00
|
|
|
}
|
2022-02-09 22:54:52 -08:00
|
|
|
shared_vpc_service_config = local.shared_vpc_project == null ? null : {
|
2022-02-09 23:47:16 -08:00
|
|
|
attach = true
|
|
|
|
host_project = local.shared_vpc_project
|
|
|
|
service_identity_iam = {}
|
|
|
|
# service_identity_iam = {
|
|
|
|
# "roles/composer.sharedVpcAgent" = [
|
|
|
|
# "composer"
|
|
|
|
# ]
|
|
|
|
# "roles/compute.networkUser" = [
|
|
|
|
# "cloudservices", "container-engine", "dataflow"
|
|
|
|
# ]
|
|
|
|
# "roles/container.hostServiceAgentUser" = [
|
|
|
|
# "container-engine"
|
|
|
|
# ]
|
|
|
|
# }
|
2022-02-09 22:54:52 -08:00
|
|
|
}
|
2022-02-09 08:01:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Cloud Storage
|
|
|
|
|
|
|
|
module "orch-cs-0" {
|
|
|
|
source = "../../../modules/gcs"
|
|
|
|
project_id = module.orch-project.project_id
|
|
|
|
prefix = var.prefix
|
|
|
|
name = "orc-cs-0"
|
|
|
|
location = var.region
|
|
|
|
storage_class = "REGIONAL"
|
|
|
|
encryption_key = try(local.service_encryption_keys.storage, null)
|
2022-01-17 23:58:14 -08:00
|
|
|
}
|
2022-02-01 00:30:29 -08:00
|
|
|
|
2022-02-09 08:01:25 -08:00
|
|
|
# internal VPC resources
|
|
|
|
|
|
|
|
module "orch-vpc" {
|
2022-02-01 00:30:29 -08:00
|
|
|
source = "../../../modules/net-vpc"
|
2022-02-09 08:01:25 -08:00
|
|
|
count = local.use_shared_vpc ? 0 : 1
|
|
|
|
project_id = module.orch-project.project_id
|
|
|
|
name = "${var.prefix}-default"
|
2022-02-01 00:30:29 -08:00
|
|
|
subnets = [
|
|
|
|
{
|
2022-02-07 12:28:54 -08:00
|
|
|
ip_cidr_range = "10.10.0.0/24"
|
2022-02-09 08:01:25 -08:00
|
|
|
name = "default"
|
|
|
|
region = var.region
|
2022-02-01 00:30:29 -08:00
|
|
|
secondary_ip_range = {
|
2022-02-07 12:28:54 -08:00
|
|
|
pods = "10.10.8.0/22"
|
|
|
|
services = "10.10.12.0/24"
|
2022-02-01 00:30:29 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2022-02-09 08:01:25 -08:00
|
|
|
module "orch-vpc-firewall" {
|
2022-02-01 00:30:29 -08:00
|
|
|
source = "../../../modules/net-vpc-firewall"
|
2022-02-09 08:01:25 -08:00
|
|
|
count = local.use_shared_vpc ? 0 : 1
|
|
|
|
project_id = module.orch-project.project_id
|
|
|
|
network = module.orch-vpc.0.name
|
2022-02-07 12:28:54 -08:00
|
|
|
admin_ranges = ["10.10.0.0/24"]
|
2022-02-01 00:30:29 -08:00
|
|
|
}
|
|
|
|
|
2022-02-09 08:01:25 -08:00
|
|
|
module "orch-nat" {
|
|
|
|
count = local.use_shared_vpc ? 0 : 1
|
2022-02-01 00:30:29 -08:00
|
|
|
source = "../../../modules/net-cloudnat"
|
2022-02-09 08:01:25 -08:00
|
|
|
project_id = module.orch-project.project_id
|
|
|
|
name = "${var.prefix}-default"
|
|
|
|
region = var.region
|
|
|
|
router_network = module.orch-vpc.0.name
|
2022-02-01 00:30:29 -08:00
|
|
|
}
|