forked from GoogleCloudPlatform/cloud-foundation-fabric
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
87 lines (85 loc) · 2.86 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# 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.
locals {
iam = {
"roles/iam.serviceAccountUser" = [
module.service-account-orch.iam_email
]
"roles/iam.serviceAccountTokenCreator" = var.data_eng_principals
# GCS roles
"roles/storage.objectAdmin" = [
module.service-account-df.iam_email,
module.service-account-landing.iam_email
]
# BigQuery roles
"roles/bigquery.admin" = var.data_eng_principals
"roles/bigquery.dataOwner" = [
module.service-account-df.iam_email
]
"roles/bigquery.dataViewer" = [
module.service-account-bq.iam_email
]
"roles/bigquery.jobUser" = [
module.service-account-bq.iam_email
]
# Compute
"roles/compute.viewer" = var.data_eng_principals
# Dataflow roles
"roles/dataflow.admin" = concat(
[module.service-account-orch.iam_email],
var.data_eng_principals
)
"roles/dataflow.developer" = var.data_eng_principals
"roles/dataflow.worker" = [
module.service-account-df.iam_email,
]
}
network_subnet_selflink = try(
module.vpc[0].subnets["${var.region}/subnet"].self_link,
var.network_config.subnet_self_link
)
shared_vpc_bindings = {
"roles/compute.networkUser" = [
"robot-df", "sa-df-worker"
]
}
}
module "project" {
source = "../../../modules/project"
name = var.project_config.project_id
parent = var.project_config.parent
billing_account = var.project_config.billing_account_id
project_create = var.project_config.billing_account_id != null
prefix = var.project_config.billing_account_id == null ? null : var.prefix
services = [
"bigquery.googleapis.com",
"bigquerystorage.googleapis.com",
"bigqueryreservation.googleapis.com",
"cloudkms.googleapis.com",
"compute.googleapis.com",
"dataflow.googleapis.com",
"servicenetworking.googleapis.com",
"storage.googleapis.com",
"storage-component.googleapis.com",
]
iam = var.project_config.billing_account_id != null ? local.iam : {}
iam_additive = var.project_config.billing_account_id == null ? local.iam : {}
shared_vpc_service_config = var.network_config.host_project == null ? null : {
attach = true
host_project = var.network_config.host_project
service_identity_iam = {
"roles/compute.networkUser" = ["dataflow"]
}
}
}