forked from dominodatalab/terraform-gcp-gke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice-accounts.tf
45 lines (37 loc) · 1.61 KB
/
service-accounts.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
locals {
service_accounts = toset(["platform", "gcr"])
}
resource "google_service_account" "accounts" {
for_each = local.service_accounts
account_id = "${var.cluster_name}-${each.value}"
display_name = "${var.cluster_name}-${each.value}"
}
resource "google_project_iam_member" "service_account" {
for_each = local.service_accounts
project = var.project
role = "roles/iam.serviceAccountUser"
member = "serviceAccount:${google_service_account.accounts[each.value].email}"
}
resource "google_project_iam_member" "platform_roles" {
for_each = toset(["roles/storage.objectAdmin", "roles/logging.logWriter", "roles/monitoring.metricWriter"])
project = var.project
role = each.value
member = "serviceAccount:${google_service_account.accounts["platform"].email}"
}
resource "google_service_account_iam_binding" "platform_gcs" {
service_account_id = google_service_account.accounts["platform"].name
role = "roles/iam.workloadIdentityUser"
members = [
"serviceAccount:${var.project}.svc.id.goog[${var.namespaces.platform}/docker-registry]",
"serviceAccount:${var.project}.svc.id.goog[${var.namespaces.platform}/domino-data-importer]",
"serviceAccount:${var.project}.svc.id.goog[${var.namespaces.platform}/git]",
"serviceAccount:${var.project}.svc.id.goog[${var.namespaces.platform}/nucleus]",
]
}
resource "google_service_account_iam_binding" "gcr" {
service_account_id = google_service_account.accounts["gcr"].name
role = "roles/iam.workloadIdentityUser"
members = [
"serviceAccount:${var.project}.svc.id.goog[${var.namespaces.compute}/forge]",
]
}