Last active
June 12, 2020 17:09
-
-
Save magickatt/c69ef5ed509f3033d1d6f4f805a92a1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
project_ids = [123456789012, 234567890123, 345678901234] | |
bucket_region = "us" | |
bucket_project = "something-123456" | |
bucket_name = "${local.bucket_region}.artifacts.${local.bucket_project}.appspot.com" | |
} | |
# Allow Cloud Build in every other project access to GCR images hosted in the central project | |
resource "google_storage_bucket_iam_member" "container_registry" { | |
for_each = var.project_ids | |
bucket = local.bucket_name | |
role = "roles/storage.objectViewer" | |
member = "serviceAccount:${each.value}@cloudbuild.gserviceaccount.com" | |
} | |
# Allow GCE/GKE in every other project access to GCR images hosted in the central project | |
resource "google_storage_bucket_iam_member" "container_registry" { | |
for_each = var.project_ids | |
bucket = local.bucket_name | |
role = "roles/storage.objectViewer" | |
member = "serviceAccount:${each.value}-compute@developer.gserviceaccount.com" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment