2022-01-13 23:38:26 -08:00
|
|
|
# Copyright 2022 Google LLC
|
2021-12-24 02:21:42 -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
|
|
|
|
#
|
|
|
|
# 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-01-13 23:45:14 -08:00
|
|
|
# Projects #
|
2021-12-24 02:21:42 -08:00
|
|
|
###############################################################################
|
|
|
|
|
2022-01-14 04:55:47 -08:00
|
|
|
module "project" {
|
2022-01-14 01:28:19 -08:00
|
|
|
source = "../../../modules/project"
|
2022-01-14 04:55:47 -08:00
|
|
|
name = var.project_id
|
|
|
|
parent = try(var.project_create.parent, null)
|
|
|
|
billing_account = try(var.project_create.billing_account_id, null)
|
|
|
|
project_create = var.project_create != null
|
|
|
|
prefix = var.project_create == null ? null : var.prefix
|
2021-12-24 02:21:42 -08:00
|
|
|
services = [
|
|
|
|
"bigquery.googleapis.com",
|
|
|
|
"bigquerystorage.googleapis.com",
|
|
|
|
"bigqueryreservation.googleapis.com",
|
2022-01-14 07:59:10 -08:00
|
|
|
"cloudkms.googleapis.com",
|
|
|
|
"compute.googleapis.com",
|
2022-01-14 08:54:29 -08:00
|
|
|
"dataflow.googleapis.com",
|
2022-01-14 07:59:10 -08:00
|
|
|
"servicenetworking.googleapis.com",
|
|
|
|
"storage.googleapis.com",
|
|
|
|
"storage-component.googleapis.com",
|
2021-12-24 02:21:42 -08:00
|
|
|
]
|
2022-01-14 08:54:29 -08:00
|
|
|
# additive IAM bindings avoid disrupting bindings in existing project
|
2022-01-14 07:59:10 -08:00
|
|
|
iam = {
|
2021-12-24 02:21:42 -08:00
|
|
|
# GCS roles
|
|
|
|
"roles/storage.objectAdmin" = [
|
|
|
|
module.service-account-df.iam_email,
|
|
|
|
module.service-account-landing.iam_email
|
|
|
|
],
|
|
|
|
"roles/storage.objectViewer" = [
|
|
|
|
module.service-account-orch.iam_email,
|
|
|
|
],
|
2022-01-14 08:55:12 -08:00
|
|
|
# BigQuery roles
|
2022-01-14 07:59:10 -08:00
|
|
|
"roles/bigquery.admin" = concat([
|
2021-12-24 02:21:42 -08:00
|
|
|
module.service-account-orch.iam_email,
|
2022-01-14 07:59:10 -08:00
|
|
|
], var.data_eng_principals
|
|
|
|
)
|
2021-12-24 02:21:42 -08:00
|
|
|
"roles/bigquery.dataEditor" = [
|
|
|
|
module.service-account-df.iam_email,
|
2022-01-14 04:55:47 -08:00
|
|
|
module.service-account-bq.iam_email
|
2021-12-24 02:21:42 -08:00
|
|
|
]
|
|
|
|
"roles/bigquery.dataViewer" = [
|
|
|
|
module.service-account-bq.iam_email,
|
|
|
|
module.service-account-orch.iam_email
|
|
|
|
]
|
|
|
|
"roles/bigquery.jobUser" = [
|
2022-01-14 04:55:47 -08:00
|
|
|
module.service-account-df.iam_email,
|
|
|
|
module.service-account-bq.iam_email
|
2021-12-24 02:21:42 -08:00
|
|
|
]
|
|
|
|
"roles/bigquery.user" = [
|
|
|
|
module.service-account-bq.iam_email,
|
|
|
|
module.service-account-df.iam_email
|
|
|
|
]
|
2022-01-14 08:55:12 -08:00
|
|
|
# common roles
|
2021-12-24 02:21:42 -08:00
|
|
|
"roles/logging.logWriter" = [
|
|
|
|
module.service-account-bq.iam_email,
|
|
|
|
module.service-account-landing.iam_email,
|
|
|
|
module.service-account-orch.iam_email,
|
|
|
|
]
|
|
|
|
"roles/monitoring.metricWriter" = [
|
|
|
|
module.service-account-bq.iam_email,
|
|
|
|
module.service-account-landing.iam_email,
|
|
|
|
module.service-account-orch.iam_email,
|
|
|
|
]
|
|
|
|
"roles/iam.serviceAccountUser" = [
|
|
|
|
module.service-account-orch.iam_email,
|
|
|
|
]
|
2022-01-14 00:32:15 -08:00
|
|
|
"roles/iam.serviceAccountTokenCreator" = concat(
|
2022-01-14 04:55:47 -08:00
|
|
|
var.data_eng_principals,
|
2022-01-14 00:32:15 -08:00
|
|
|
)
|
|
|
|
"roles/viewer" = concat(
|
2022-01-14 04:55:47 -08:00
|
|
|
var.data_eng_principals
|
2022-01-14 00:32:15 -08:00
|
|
|
)
|
2022-01-14 08:55:12 -08:00
|
|
|
# Dataflow roles
|
2022-01-14 04:55:47 -08:00
|
|
|
"roles/dataflow.admin" = concat([
|
2022-01-13 23:50:58 -08:00
|
|
|
module.service-account-orch.iam_email,
|
2022-01-14 04:55:47 -08:00
|
|
|
], var.data_eng_principals
|
|
|
|
)
|
2022-01-14 01:28:19 -08:00
|
|
|
"roles/dataflow.worker" = [
|
|
|
|
module.service-account-df.iam_email,
|
|
|
|
]
|
2022-01-14 08:55:12 -08:00
|
|
|
# network roles
|
2022-01-14 01:28:19 -08:00
|
|
|
"roles/compute.networkUser" = [
|
|
|
|
module.service-account-df.iam_email,
|
2022-01-14 04:55:47 -08:00
|
|
|
"serviceAccount:${module.project.service_accounts.robots.dataflow}"
|
2022-01-14 01:28:19 -08:00
|
|
|
]
|
2022-01-13 23:50:58 -08:00
|
|
|
}
|
2022-01-14 04:55:47 -08:00
|
|
|
service_config = {
|
|
|
|
disable_on_destroy = false, disable_dependent_services = false
|
2021-12-24 02:21:42 -08:00
|
|
|
}
|
|
|
|
}
|