Question

Difficulty: HardConfiguring Service Account Impersonation and Workload Identity

A security lead mandates that developers executing maintenance scripts from their local workstations must access BigQuery datasets as the target service account [email protected] without downloading service account keys. Which of the following configurations are required to establish valid service account impersonation for the developer account [email protected]? (Select TWO correct answers.)

  1. Grant [email protected] the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) on the target service account resource.Answer
  2. Execute gcloud commands with the --impersonate-service-account=data-exporter@analytics-prod.iam.gserviceaccount.com flag or set the corresponding gcloud configuration property.Answer
  3. C
    Generate a short-lived JSON key pair using gcloud iam service-accounts keys create and store it in local user environment variables.
  4. D
    Assign the primitive Owner role (roles/owner) to [email protected] at the project level to bypass explicit IAM token creation delegation.

Answer

To configure service account impersonation using the gcloud CLI without service account keys, grant the user the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) on the target service account and execute commands using the --impersonate-service-account flag.
Establishing secure keyless service account impersonation requires granting the requesting principal the Service Account Token Creator role on the target service account and configuring local CLI tools using the --impersonate-service-account flag to request short-lived access tokens dynamically.

Step-by-Step Solution

1
Identify the required IAM permissions for token generation
The principal performing impersonation requires the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) on the target service account.
Impersonation relies on generating short-lived OAuth 2.0 access tokens or signed JWTs on behalf of the service account.
2
Configure the client tooling to use short-lived credentials
Pass the --impersonate-service-account flag with gcloud commands or configure auth/impersonate_service_account.
This instructs gcloud to authenticate requests via credentials minted from the target service account rather than the user's primary credentials.

Key Concept

Service Account Impersonation via gcloud CLI
Rate this question