2021-01-01 21:49:51 +03:00
|
|
|
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
2019-04-04 11:33:38 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
// Setup the Nix bucket + CDN
|
|
|
|
locals {
|
|
|
|
nix_cache_name = "daml-nix-cache"
|
|
|
|
|
|
|
|
// see main.tf for additional locals
|
|
|
|
}
|
|
|
|
|
|
|
|
module "nix_cache" {
|
|
|
|
source = "./modules/gcp_cdn_bucket"
|
|
|
|
|
2021-02-08 20:25:04 +03:00
|
|
|
labels = local.labels
|
|
|
|
name = local.nix_cache_name
|
|
|
|
project = local.project
|
|
|
|
region = local.region
|
2020-09-17 18:36:35 +03:00
|
|
|
ssl_certificate = "https://www.googleapis.com/compute/v1/projects/da-dev-gcp-daml-language/global/sslCertificates/nix-cache"
|
2020-06-20 17:25:02 +03:00
|
|
|
cache_retention_days = 360
|
2019-04-04 11:33:38 +03:00
|
|
|
}
|
|
|
|
|
2019-05-01 18:54:09 +03:00
|
|
|
// allow rw access for CI writer (see writer.tf)
|
2020-09-18 16:59:23 +03:00
|
|
|
resource "google_storage_bucket_iam_member" "nix_cache_writer_create" {
|
2021-02-08 20:25:04 +03:00
|
|
|
bucket = module.nix_cache.bucket_name
|
2019-04-04 11:33:38 +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}"
|
|
|
|
}
|
|
|
|
resource "google_storage_bucket_iam_member" "nix_cache_writer_read" {
|
2021-02-08 20:25:04 +03:00
|
|
|
bucket = module.nix_cache.bucket_name
|
2020-09-18 16:59:23 +03:00
|
|
|
|
|
|
|
# https://cloud.google.com/storage/docs/access-control/iam-roles
|
|
|
|
role = "roles/storage.objectViewer"
|
2019-04-04 11:33:38 +03:00
|
|
|
member = "serviceAccount:${google_service_account.writer.email}"
|
|
|
|
}
|
|
|
|
|
|
|
|
output "nix_cache_ip" {
|
2021-02-08 20:25:04 +03:00
|
|
|
value = module.nix_cache.external_ip
|
2019-04-04 11:33:38 +03:00
|
|
|
}
|