A data analyst must execute a scheduled Python script from an on-premises workstation to pull analytics data from BigQuery using a dedicated service account named `[email protected]`. Organization security policies explicitly prohibit generating or downloading long-lived service account JSON key files to local machines. The analyst has already authenticated their personal user identity using `gcloud auth login`. Which configuration best satisfies this security requirement while adhering to the principle of least privilege?
- Grant the data analyst's user account the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) on the target service account.Answer
- BGenerate a service account JSON key file for `bq-reader` and set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable on the workstation.
- CGrant the data analyst's user account the primitive Owner role (`roles/owner`) at the project level.
- DGrant the data analyst's user account the Service Account User role (`roles/iam.serviceAccountUser`) at the organization level so it overrides resource-level restrictions.
Answer
Grant the data analyst's user account the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) on the target service account.
Granting the Service Account Token Creator role (`roles/iam.serviceAccountTokenCreator`) directly on the target service account enables the user to generate short-lived credentials via `gcloud` or Google API client libraries. This completely removes the need for long-lived JSON service account keys while adhering to the principle of least privilege.
Step-by-Step Solution
Key Concept
Service Account Impersonation via Service Account Token Creator Role
Estimated Time:1m 30s