A security mandate for a Google Cloud project named `analytics-prod` prohibits developers from generating or downloading long-lived JSON service account keys. A cloud engineer using the identity `[email protected]` needs temporary authorization to mint short-lived OAuth 2.0 access tokens for an existing service account named `[email protected]`. Which command should an administrator run to grant the engineer the necessary permission directly on the service account using the principle of least privilege?
- gcloud iam service-accounts add-iam-policy-binding [email protected] --member="user:[email protected]" --role="roles/iam.serviceAccountTokenCreator"Cevap
- Bgcloud iam service-accounts keys create key.json --iam-account=data-pipeline@analytics-prod.iam.gserviceaccount.com
- Cgcloud projects add-iam-policy-binding analytics-prod --member="user:[email protected]" --role="roles/editor"
- Dgcloud projects add-iam-policy-binding analytics-prod --member="user:[email protected]" --role="roles/iam.serviceAccountUser"
Cevap
Execute the `gcloud iam service-accounts add-iam-policy-binding` command targeting the specific service account and assigning the `roles/iam.serviceAccountTokenCreator` role to the user.
To allow a developer to generate short-lived access tokens for a service account without key creation, the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) should be bound directly to the target service account resource using `gcloud iam service-accounts add-iam-policy-binding`.
Adım Adım Çözüm
Anahtar Kavram
Managing Service Account Impersonation and Token Creation via IAM Policy Bindings
Tahmini Süre:1m 30s