An organization mandates that infrastructure deployments executed by developers from their local workstations to the production project `proj-landing-zone` must use short-lived credentials. Long-lived service account JSON keys are explicitly prohibited by organizational policy. A dedicated service account `[email protected]` has already been assigned all necessary resource management permissions in `proj-landing-zone`. To enable developers to execute `gcloud auth application-default login --impersonate-service-account=sa-terraform-deployer@proj-landing-zone.iam.gserviceaccount.com` without granting them direct permissions to modify resources in the project, which IAM configuration is required?
- Grant the developer group the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) directly on [email protected].Answer
- BGrant the developer group the Service Account User role (roles/iam.serviceAccountUser) directly on [email protected].
- CGrant the developer group the Editor role (roles/editor) at the proj-landing-zone project level so that permissions inherit to the service account.
- DExport a service account JSON key for [email protected] and have developers set the GOOGLE_APPLICATION_CREDENTIALS environment variable.
Answer
Grant the developer group the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) directly on the target service account resource.
To impersonate a service account using gcloud CLI or Application Default Credentials (ADC) short-lived token generation, the calling principal must be granted the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`). Granting this role directly on the specific service account adheres to the principle of least privilege and avoids using long-lived JSON service account keys.
Step-by-Step Solution
Key Concept
Service Account Impersonation and Token Creation Roles