An infrastructure administrator needs to enable an external automation tool running on a developer workstation to mint short-lived OAuth 2.0 access tokens for a specific target service account named `[email protected]`. The organization strictly prohibits creating long-lived private key files and mandates enforcing least-privilege access. Which `gcloud` command accurately grants the minimum required permission to the developer user `[email protected]` on the target service account?
- gcloud iam service-accounts add-iam-policy-binding [email protected] --member="user:[email protected]" --role="roles/iam.serviceAccountTokenCreator"Answer
- Bgcloud iam service-accounts keys create key.json --iam-account=data-pipeline-sa@prod-analytics-1234.iam.gserviceaccount.com
- Cgcloud projects add-iam-policy-binding prod-analytics-1234 --member="user:[email protected]" --role="roles/editor"
- Dgcloud services enable iamcredentials.googleapis.com --project=prod-analytics-1234
Answer
The command running `gcloud iam service-accounts add-iam-policy-binding` with the target service account email, assigning the `user:[email protected]` the role `roles/iam.serviceAccountTokenCreator` directly on the resource.
The correct command binds the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) directly to the identity on the specific service account resource. This enables token generation and service account impersonation dynamically without requiring static key exports.
Step-by-Step Solution
Key Concept
Service Account Impersonation and Token Creation Roles