What this thread does
Do first: create a dedicated runtime service account and deploy with gcloud run deploy SERVICE --image IMAGE_URL --service-account SERVICE_ACCOUNT_EMAIL after granting its required resource access.
Short answer
As of November 2026, use current Google Cloud docs. The deployer needs permission to attach the account; Grant deployment and runtime permissions separately. Identity, account permissions.
Choose / don't choose
- Predefined role: choose the smallest role matching real API calls at the narrowest supported resource; don't default to project Editor. No access to other Google Cloud services means no service-identity roles or permissions are required. Service identity.
- Custom role: choose when predefined roles retain material excess permissions and the team can maintain an explicit supported permission set; don't create a role merely to rename a broad grant. Use
gcloud iam roles create ROLE_ID --project=PROJECT_ID --file=FILE. Custom roles, CLI. - Conditional project binding: choose only when project scope is necessary and supported request/resource attributes express the boundary; don't use
--condition=Noneexpecting a restriction. Binding reference.
Not for: GitHub Actions OIDC role assumption; see github-actions-oidc-credentials-runner-communication-errors.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
gcloud run deploy --service-account | Documented SERVICE_ACCOUNT deployment argument | Current Cloud Run | Identity |
gcloud projects add-iam-policy-binding --member | serviceAccount:SERVICE_ACCOUNT_EMAIL for runtime grants | Current gcloud IAM | Binding reference |
--role on the account's IAM policy | roles/iam.serviceAccountUser to the deployer on this one account; includes iam.serviceAccounts.actAs | Account attachment, not application-data access | Identity |
gcloud projects add-iam-policy-binding --condition | Required title and CEL expression; None creates an unconditional binding; nonempty conditions cannot accompany basic roles | Current gcloud | Binding reference |
gcloud projects remove-iam-policy-binding --condition | None removes unconditional member/role binding; otherwise exact condition including description; avoid --all for a narrow removal | Current gcloud | Removal reference |
gcloud iam roles create --permissions / --project | required supported permissions, or --file=FILE; project ID scopes the custom role definition | Current gcloud | Role creation |
Jani Patokallio and John McGovern's October 3, 2019 least-privilege article recommends more specific predefined roles or custom roles. Etienne De Burgh and Aakashi Kapoor's March 20, 2024 default-policy announcement recommends dedicated accounts and restricting automatic broad default-account grants. Inspect actual policies rather than infer permissions from account type.
Order of operations
1. Record API calls, target resources and effective inherited grants. Create the new account; grant narrow roles on target resources where possible, otherwise review project-level binding conditions. Keep service agents distinct from the app's identity. Account practices. 2. Grant the deployer roles/iam.serviceAccountUser on the new account, plus its separate deployment permissions. Attach the new account explicitly and inspect the deployed revision's service identity. Identity. 3. Exercise startup and representative resource operations under the new account, including negative access checks. A new account without the old Editor grant gives meaningful evidence; adding narrow grants alongside Editor on the same identity does not. Review custom roles when API requirements change. Practices, custom roles. 4. Move traffic after observing the narrow identity's behavior. Inventory old revisions, scheduled jobs and other services still using the old identity before removing its broad project grant. Preserve a rollback policy snapshot. Removal.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|---|---|---|
iam.serviceaccounts.actAs | Default Compute Engine service account missing and no --service-account specified, or deployer lacks required permissions | Confirm chosen email exists and grant deployer Account User on that account; do not add runtime Editor | Deployment diagnostic |
iam.serviceAccounts.getAccessToken | Cloud Run Service Agent lacks permission to get access tokens for the service account | Check service agent's Token Creator grant under the documented configuration | Service-agent diagnostic |
| Runtime resource access denied | Service identity needs the permissions or roles required by intended operations | Inspect denied principal/action/resource in audit logs and narrow resource policy | Identity roles |
markgoho's September 9, 2026 issue inventoried a Cloud Run API running as a default Editor account and called for a dedicated identity; it closed as completed on 2026-09-10. Its application-specific role list is not a portable grant template.
Missing
- The linked source confirms: the running account needs the roles or permissions required by its operations.
- The linked source confirms: a role on a service account controls use of that identity, not its access to application data.
- The linked source confirms:
actAsauthorizes attachment; runtime calls need the service identity’s required roles or permissions. - Exact application-data
--roleand--conditionexpression cannot be chosen without API operations, resource inventory and supported condition attributes. The dedicated email is also a deployment input; example addresses are placeholders.
Checked
2026-11-12; current docs, November 2026. Sources read: linked identity, permissions, binding/removal, role creation, practices, troubleshooting two dated Google Cloud articles and markgoho issue. No IAM or deployment commands executed.
Started from a post by @Google Cloud, packaged by the editor. Original post