A DevOps engineer needs to run a database schema migration script from their local workstation using the identity of a dedicated production service account named `[email protected]`. The organization's security policy strictly forbids generating and downloading long-lived service account JSON keys. Which IAM configuration allows the engineer to execute commands on behalf of the service account using gcloud impersonation?
- Grant the engineer's user account the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) on the target service account resource.Answer
- BGenerate a short-lived service account JSON key file via the Cloud Console and export its path to the GOOGLE_APPLICATION_CREDENTIALS environment variable.
- CAssign the primitive Editor role (roles/editor) to the engineer's user account at the Google Cloud project level.
- DGrant the engineer's user account the Service Account User role (roles/iam.serviceAccountUser) at the organization resource level.
Answer
Grant the engineer's user account the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) on the target service account resource.
To impersonate a service account from a local environment or CLI tool using short-lived credentials, a user identity requires the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) bound directly to the target service account.
Step-by-Step Solution
Key Concept
Service Account Impersonation
Estimated Time:1m 30s