Skip to content

Commit 93b7f7a

Browse files
committed
FIX: Give GHA service account access to bucket
1 parent 8a549e3 commit 93b7f7a

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

iam_roles_github_actions.tf

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
resource "google_project_iam_member" "github_actions__roles" {
2+
for_each = toset(
3+
[
4+
"roles/iam.serviceAccountUser",
5+
"roles/pubsub.editor",
6+
"roles/errorreporting.writer",
7+
"roles/artifactregistry.writer",
8+
"roles/storage.objectAdmin",
9+
# Allows the GHA to call "namespaces get" for Cloud Run to determine the resulting run URLs of the services.
10+
# This should also allow a service to get its own name by using:
11+
# https://stackoverflow.com/questions/65628822/google-cloud-run-can-a-service-know-its-own-url/65634104#65634104
12+
"roles/run.developer",
13+
]
14+
)
15+
project = var.google_cloud_project_id
16+
role = each.value
17+
member = "serviceAccount:${google_service_account.github_actions_service_account.email}"
18+
depends_on = [time_sleep.wait_for_google_apis_to_enable]
19+
}
20+
21+
22+
resource "google_storage_bucket_iam_member" "github_actions__default_bucket__storage__object_admin" {
23+
bucket = google_storage_bucket.default.name
24+
role = "roles/storage.objectAdmin"
25+
member = "serviceAccount:${google_service_account.github_actions_service_account.email}"
26+
}

iam_service_accounts.tf

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,6 @@ resource "google_service_account" "github_actions_service_account" {
77
}
88

99

10-
resource "google_project_iam_member" "github_actions__roles" {
11-
for_each = toset(
12-
[
13-
"roles/iam.serviceAccountUser",
14-
"roles/pubsub.editor",
15-
"roles/errorreporting.writer",
16-
"roles/artifactregistry.writer",
17-
"roles/storage.objectAdmin",
18-
# Allows the GHA to call "namespaces get" for Cloud Run to determine the resulting run URLs of the services.
19-
# This should also allow a service to get its own name by using:
20-
# https://stackoverflow.com/questions/65628822/google-cloud-run-can-a-service-know-its-own-url/65634104#65634104
21-
"roles/run.developer",
22-
]
23-
)
24-
project = var.google_cloud_project_id
25-
role = each.value
26-
member = "serviceAccount:${google_service_account.github_actions_service_account.email}"
27-
depends_on = [time_sleep.wait_for_google_apis_to_enable]
28-
}
29-
30-
3110
resource "google_service_account" "developers" {
3211
for_each = var.developer_service_account_names
3312
account_id = each.key

0 commit comments

Comments
 (0)