2021-01-01 21:49:51 +03:00
|
|
|
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
2019-07-04 14:23:51 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
resource "google_storage_bucket" "data" {
|
2021-02-08 20:25:04 +03:00
|
|
|
project = local.project
|
2019-07-04 14:23:51 +03:00
|
|
|
name = "daml-data"
|
2021-02-08 20:25:04 +03:00
|
|
|
labels = local.labels
|
2019-07-04 14:23:51 +03:00
|
|
|
|
|
|
|
# SLA is enough for a cache and is cheaper than MULTI_REGIONAL
|
|
|
|
# see https://cloud.google.com/storage/docs/storage-classes
|
|
|
|
storage_class = "REGIONAL"
|
|
|
|
|
|
|
|
# Use a normal region since the storage_class is regional
|
2021-02-08 20:25:04 +03:00
|
|
|
location = local.region
|
2020-09-18 16:59:23 +03:00
|
|
|
|
|
|
|
versioning {
|
|
|
|
enabled = true
|
|
|
|
}
|
2019-07-04 14:23:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "google_storage_bucket_acl" "data" {
|
2021-02-08 20:25:04 +03:00
|
|
|
bucket = google_storage_bucket.data.name
|
2019-07-04 14:23:51 +03:00
|
|
|
|
|
|
|
role_entity = [
|
|
|
|
"OWNER:project-owners-${data.google_project.current.number}",
|
|
|
|
"OWNER:project-editors-${data.google_project.current.number}",
|
|
|
|
"READER:project-viewers-${data.google_project.current.number}",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
// allow rw access for CI writer (see writer.tf)
|
2020-09-18 16:59:23 +03:00
|
|
|
resource "google_storage_bucket_iam_member" "data_create" {
|
2021-02-08 20:25:04 +03:00
|
|
|
bucket = google_storage_bucket.data.name
|
2019-07-04 14:23:51 +03:00
|
|
|
|
|
|
|
# https://cloud.google.com/storage/docs/access-control/iam-roles
|
2020-09-18 16:59:23 +03:00
|
|
|
role = "roles/storage.objectCreator"
|
|
|
|
member = "serviceAccount:${google_service_account.writer.email}"
|
|
|
|
}
|
2021-01-28 14:11:08 +03:00
|
|
|
|
2020-09-18 16:59:23 +03:00
|
|
|
resource "google_storage_bucket_iam_member" "data_read" {
|
2021-02-08 20:25:04 +03:00
|
|
|
bucket = google_storage_bucket.data.name
|
2020-09-18 16:59:23 +03:00
|
|
|
|
|
|
|
# https://cloud.google.com/storage/docs/access-control/iam-roles
|
|
|
|
role = "roles/storage.objectViewer"
|
2019-07-04 14:23:51 +03:00
|
|
|
member = "serviceAccount:${google_service_account.writer.email}"
|
|
|
|
}
|
2020-09-16 19:25:23 +03:00
|
|
|
|
|
|
|
// allow read access for appr team, as requested by Moritz
|
2021-07-09 14:41:46 +03:00
|
|
|
locals {
|
|
|
|
appr_team = [
|
2021-07-09 13:55:16 +03:00
|
|
|
"user:akshay.shirahatti@digitalasset.com",
|
2020-09-16 19:25:23 +03:00
|
|
|
"user:andreas.herrmann@digitalasset.com",
|
|
|
|
"user:gary.verhaegen@digitalasset.com",
|
|
|
|
"user:moritz.kiefer@digitalasset.com",
|
2021-01-28 14:11:08 +03:00
|
|
|
"user:stefano.baghino@digitalasset.com",
|
2020-09-16 19:25:23 +03:00
|
|
|
"user:stephen.compall@digitalasset.com",
|
2021-05-04 14:35:28 +03:00
|
|
|
"user:victor.mueller@digitalasset.com",
|
2020-09-16 19:25:23 +03:00
|
|
|
]
|
|
|
|
}
|
2021-01-28 14:11:08 +03:00
|
|
|
|
2020-09-16 19:25:23 +03:00
|
|
|
resource "google_storage_bucket_iam_member" "appr" {
|
2021-07-09 14:41:46 +03:00
|
|
|
for_each = toset(local.appr_team)
|
|
|
|
bucket = google_storage_bucket.data.name
|
|
|
|
role = "roles/storage.objectViewer"
|
|
|
|
member = each.key
|
2020-09-16 19:25:23 +03:00
|
|
|
}
|