Skip to content

Commit 6002b5c

Browse files
jeropleehagoodjames
andcommitted
Add required permission to service account
Given that we're using service account, which is required to get OAuth tokens needed for Code Assist, we have switched from "Direct Workload Identity Federation" to "Workload Identity Federation through a Service Account". For this reason, we need to add the right permissions to the service account. In future work, we'll remove the direct permissions in WIF. Co-authored-by: Lee Hagood James <leehagoodjames@google.com>
1 parent c1a873f commit 6002b5c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

scripts/setup_workload_identity.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,40 @@ gcloud projects add-iam-policy-binding "${GOOGLE_CLOUD_PROJECT}" \
316316

317317
# Allow the service account to generate an access tokens
318318
print_info "Granting 'Service Account Token Creator' role to Service Account..."
319+
319320
gcloud projects add-iam-policy-binding "${GOOGLE_CLOUD_PROJECT}" \
320321
--role="roles/iam.serviceAccountTokenCreator" \
321322
--member="serviceAccount:${SERVICE_ACCOUNT_EMAIL}" \
322323
--condition=None
323324

325+
# Grant logging permissions to the service account
326+
print_info "Granting 'Logging Writer' role to Service Account..."
327+
gcloud projects add-iam-policy-binding "${GOOGLE_CLOUD_PROJECT}" \
328+
--role="roles/logging.logWriter" \
329+
--member="serviceAccount:${SERVICE_ACCOUNT_EMAIL}" \
330+
--condition=None
331+
332+
# Grant monitoring permissions to the service account
333+
print_info "Granting 'Monitoring Editor' role to Service Account..."
334+
gcloud projects add-iam-policy-binding "${GOOGLE_CLOUD_PROJECT}" \
335+
--role="roles/monitoring.editor" \
336+
--member="serviceAccount:${SERVICE_ACCOUNT_EMAIL}" \
337+
--condition=None
338+
339+
# Grant tracing permissions to the service account
340+
print_info "Granting 'Cloud Trace Agent' role to Service Account..."
341+
gcloud projects add-iam-policy-binding "${GOOGLE_CLOUD_PROJECT}" \
342+
--role="roles/cloudtrace.agent" \
343+
--member="serviceAccount:${SERVICE_ACCOUNT_EMAIL}" \
344+
--condition=None
345+
346+
# Grant Vertex AI permissions to the service account
347+
print_info "Granting 'Vertex AI User' role to Service Account..."
348+
gcloud projects add-iam-policy-binding "${GOOGLE_CLOUD_PROJECT}" \
349+
--role="roles/aiplatform.user" \
350+
--member="serviceAccount:${SERVICE_ACCOUNT_EMAIL}" \
351+
--condition=None
352+
324353
# Allow the Workload Identity Pool to impersonate the Service Account
325354
print_info "Allowing GitHub Actions from '${GITHUB_REPO}' to impersonate the Service Account..."
326355
gcloud iam service-accounts add-iam-policy-binding "${SERVICE_ACCOUNT_EMAIL}" \

0 commit comments

Comments
 (0)