* Import Fast from dev repository. > > Co-authored-by: Julio Castillo <jccb@google.com> Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> Co-authored-by: Simone Ruffilli <sruffilli@google.com> * Import Fast from dev repository. > > Co-authored-by: Julio Castillo <jccb@google.com> Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> Co-authored-by: Simone Ruffilli <sruffilli@google.com> * merge tools changes * Import Fast from dev repository. > > Co-authored-by: Julio Castillo <jccb@google.com> Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> Co-authored-by: Simone Ruffilli <sruffilli@google.com> * add bolierplate to validate_schema Co-authored-by: Julio Castillo <juliocc@users.noreply.github.com> * stage 02-security * Import Fast from dev repository. Co-authored-by: Julio Castillo <jccb@google.com> Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> Co-authored-by: Simone Ruffilli <sruffilli@google.com> * Copy FAST top level README * Copy FAST top level README * TODO list * TODO list * fix linting action to account for fast * remove providers file * add missing boilerplate * update factory README * align examples tfdoc * fast readmes tfdoc * disable markdown link check * really disable markdown link check * update TODO * switch to local module refs in stage0 * replace module refs in 02-sec * Import Fast from dev repository. > > Co-authored-by: Julio Castillo <jccb@google.com> Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> Co-authored-by: Simone Ruffilli <sruffilli@google.com> * merge tools changes * Import Fast from dev repository. > > Co-authored-by: Julio Castillo <jccb@google.com> Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> Co-authored-by: Simone Ruffilli <sruffilli@google.com> * add bolierplate to validate_schema Co-authored-by: Julio Castillo <juliocc@users.noreply.github.com> * Import Fast from dev repository. > > Co-authored-by: Julio Castillo <jccb@google.com> Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> Co-authored-by: Simone Ruffilli <sruffilli@google.com> * stage 02-security * Import Fast from dev repository. Co-authored-by: Julio Castillo <jccb@google.com> Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> Co-authored-by: Simone Ruffilli <sruffilli@google.com> * Copy FAST top level README * Copy FAST top level README * TODO list * TODO list * fix linting action to account for fast * remove providers file * add missing boilerplate * update factory README * align examples tfdoc * fast readmes tfdoc * disable markdown link check * really disable markdown link check * update TODO * switch to local module refs in stage0 * replace module refs in 02-sec * Move first draft to fast branch * Fix roles and variables. Add e2e DAG example! * Fix example * Fix KMS * First draft: README * Update README * Add DLP, update README * Update Readme * README * Add todos * Merge master * Merge master * Merge master * Fix and test KMS, Fix and test existing prj (it works also with single prj), Update README * Fix READM and Demo * add on TF files * Remove block comments * simplify service_encryption_keys logic * fix README * Fix TODOs * fix tfdoc description * fix demo README * fix sample files * rename tf files * Fix outputs file name, fix README, remove dependeces on composer resource * Add test. * Fix README. * Initial README update * README review * Fix issues & readme * Fix README * Fix README * Fix test error * Fix test error * Add datacatalog * Fix test, for real? :-) * fix readme * support policy_boolean * split Cloud NAT flag * Fix README. * Fix Shared VPC, first try :-) * Fix tests and resource name * fix tests * fix tests * README refactor * Fix secondary range logic * First commit * Replace existing data platform * Fix secondary range logic * Fix README * Replace DP example tests with the new one. * Fix test module location. * Fix test module location, for real. * Support DataPlatform project in VPC-SC * Fix VPC-SC * Add TODO, VPC-SC * Possible improvement to handle VPC-SC perimeter projects with folder as variable * Add TODO * Fix module path * Initial fix for KMS * Add PubSub encryption * Fix secondary range logic * First commit * Support DataPlatform project in VPC-SC * Fix VPC-SC * Add TODO, VPC-SC * Possible improvement to handle VPC-SC perimeter projects with folder as variable * Add TODO * Fix module path * Initial fix for KMS * Update READMEs * Update README * Fix composer roles and README. * Fix test. * Fixes. * Add DLP documentation link. * Temp commit with errors * Refactor variables * Fix secondary range logic * First commit * Support DataPlatform project in VPC-SC * Fix VPC-SC * Add TODO, VPC-SC * Possible improvement to handle VPC-SC perimeter projects with folder as variable * Add TODO * Fix module path * Initial fix for KMS * rebase * rebase * rebase * Rebase * rebase * Update READMEs * Fixes. * Fix new variables * Fix misconfiguration and tests. * Fix secondary range logic * First commit * Support DataPlatform project in VPC-SC * Fix VPC-SC * Add TODO, VPC-SC * Possible improvement to handle VPC-SC perimeter projects with folder as variable * Add TODO * Fix module path * Initial fix for KMS * rebase * rebase * rebase * Rebase * rebase * Update READMEs * Fixes. * Rebase - Fix secondary range logic * Rebase - First commit * Support DataPlatform project in VPC-SC * Fix VPC-SC * Possible improvement to handle VPC-SC perimeter projects with folder as variable * Initial fix for KMS * Fix secondary range logic * First commit * Support DataPlatform project in VPC-SC * Fix VPC-SC * Fix module path * Initial fix for KMS * Update READMEs * Fixes. * Fix new variables * Revert VPC-SC logic * Fix variable typos * README fixes * Fix Project Name logic * Fix Linting * READEME * update READEME * update READEME * update README * mandatory project creation, refactor * formatting * add TODO for service accounts descriptive name * use project module to assign shared vpc roles * Fix shared-vpc-project module * Fix vpc name and tests * README * update to newer version Co-authored-by: Ludovico Magnocavallo <ludomagno@google.com> Co-authored-by: Simone Ruffilli <sruffilli@google.com> Co-authored-by: Julio Castillo <juliocc@users.noreply.github.com> Co-authored-by: Julio Castillo <jccb@google.com>
149 lines
4.5 KiB
HCL
149 lines
4.5 KiB
HCL
# 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.
|
|
|
|
# tfdoc:file:description Load project and VPC.
|
|
|
|
locals {
|
|
load_service_accounts = [
|
|
"serviceAccount:${module.load-project.service_accounts.robots.dataflow}",
|
|
module.load-sa-df-0.iam_email
|
|
]
|
|
load_subnet = (
|
|
local.use_shared_vpc
|
|
? var.network_config.subnet_self_links.orchestration
|
|
: values(module.load-vpc.0.subnet_self_links)[0]
|
|
)
|
|
load_vpc = (
|
|
local.use_shared_vpc
|
|
? var.network_config.network_self_link
|
|
: module.load-vpc.0.self_link
|
|
)
|
|
}
|
|
|
|
# Project
|
|
|
|
module "load-project" {
|
|
source = "../../../modules/project"
|
|
parent = var.folder_id
|
|
billing_account = var.billing_account_id
|
|
prefix = var.prefix
|
|
name = "lod"
|
|
group_iam = {
|
|
(local.groups.data-engineers) = [
|
|
"roles/compute.viewer",
|
|
"roles/dataflow.admin",
|
|
"roles/dataflow.developer",
|
|
"roles/viewer",
|
|
]
|
|
}
|
|
iam = {
|
|
"roles/bigquery.jobUser" = [module.load-sa-df-0.iam_email]
|
|
"roles/dataflow.admin" = [
|
|
module.orch-sa-cmp-0.iam_email, module.load-sa-df-0.iam_email
|
|
]
|
|
"roles/dataflow.worker" = [module.load-sa-df-0.iam_email]
|
|
"roles/storage.objectAdmin" = local.load_service_accounts
|
|
# TODO: these are needed on the shared VPC?
|
|
# "roles/compute.serviceAgent" = [
|
|
# "serviceAccount:${module.load-project.service_accounts.robots.compute}"
|
|
# ]
|
|
# "roles/dataflow.serviceAgent" = [
|
|
# "serviceAccount:${module.load-project.service_accounts.robots.dataflow}"
|
|
# ]
|
|
}
|
|
services = concat(var.project_services, [
|
|
"bigquery.googleapis.com",
|
|
"bigqueryreservation.googleapis.com",
|
|
"bigquerystorage.googleapis.com",
|
|
"cloudkms.googleapis.com",
|
|
"compute.googleapis.com",
|
|
"dataflow.googleapis.com",
|
|
"dlp.googleapis.com",
|
|
"pubsub.googleapis.com",
|
|
"servicenetworking.googleapis.com",
|
|
"storage.googleapis.com",
|
|
"storage-component.googleapis.com"
|
|
])
|
|
service_encryption_key_ids = {
|
|
pubsub = [try(local.service_encryption_keys.pubsub, null)]
|
|
dataflow = [try(local.service_encryption_keys.dataflow, null)]
|
|
storage = [try(local.service_encryption_keys.storage, null)]
|
|
}
|
|
shared_vpc_service_config = local.shared_vpc_project == null ? null : {
|
|
attach = true
|
|
host_project = local.shared_vpc_project
|
|
service_identity_iam = {}
|
|
# service_identity_iam = {
|
|
# "compute.networkUser" = ["dataflow"]
|
|
# }
|
|
}
|
|
}
|
|
|
|
module "load-sa-df-0" {
|
|
source = "../../../modules/iam-service-account"
|
|
project_id = module.load-project.project_id
|
|
prefix = var.prefix
|
|
name = "load-df-0"
|
|
# TODO: descriptive name
|
|
display_name = "TODO"
|
|
iam = {
|
|
"roles/iam.serviceAccountTokenCreator" = [local.groups_iam.data-engineers]
|
|
"roles/iam.serviceAccountUser" = [module.orch-sa-cmp-0.iam_email]
|
|
}
|
|
}
|
|
|
|
module "load-cs-df-0" {
|
|
source = "../../../modules/gcs"
|
|
project_id = module.load-project.project_id
|
|
prefix = var.prefix
|
|
name = "load-cs-0"
|
|
storage_class = "REGIONAL"
|
|
location = var.region
|
|
encryption_key = try(local.service_encryption_keys.storage, null)
|
|
}
|
|
|
|
# internal VPC resources
|
|
|
|
module "load-vpc" {
|
|
source = "../../../modules/net-vpc"
|
|
count = local.use_shared_vpc ? 0 : 1
|
|
project_id = module.load-project.project_id
|
|
name = "${var.prefix}-default"
|
|
subnets = [
|
|
{
|
|
ip_cidr_range = "10.10.0.0/24"
|
|
name = "default"
|
|
region = var.region
|
|
secondary_ip_range = {}
|
|
}
|
|
]
|
|
}
|
|
|
|
module "load-vpc-firewall" {
|
|
source = "../../../modules/net-vpc-firewall"
|
|
count = local.use_shared_vpc ? 0 : 1
|
|
project_id = module.load-project.project_id
|
|
network = module.load-vpc.0.name
|
|
admin_ranges = ["10.10.0.0/24"]
|
|
}
|
|
|
|
module "load-nat" {
|
|
source = "../../../modules/net-cloudnat"
|
|
count = local.use_shared_vpc ? 0 : 1
|
|
project_id = module.load-project.project_id
|
|
name = "${var.prefix}-default"
|
|
region = var.region
|
|
router_network = module.load-vpc.0.name
|
|
}
|