A platform engineer needs to configure a software developer's local environment to run Python scripts that programmatically manage Google Cloud Storage buckets using Google Cloud Client Libraries. Enterprise security policy strictly prohibits downloading JSON service account keys. The scripts must run using the identity and permissions of a target service account. Place the operational steps in the correct chronological sequence to establish secure programmatic access via Application Default Credentials (ADC) with service account impersonation.
- 1Grant the developer's user account the Service Account Token Creator role (roles/iam.serviceAccountTokenCreator) on the target service account.
- 2Run 'gcloud auth login' on the developer workstation to authenticate the developer's user identity with Google Cloud.
- 3Run 'gcloud auth application-default login --impersonate-service-account=[SA_EMAIL]' to create local Application Default Credentials.
- 4Instantiate the Google Cloud Client Library in Python code relying on standard credentials discovery without passing key paths.
Answer
The correct sequence begins with granting the user identity the Service Account Token Creator role on the target service account, followed by authenticating the user session via gcloud auth login, generating local ADC with impersonation using gcloud auth application-default login --impersonate-service-account, and finally running Python code that initializes Google Cloud Client Libraries using standard ADC auto-discovery.
To enable secure local programmatic interaction with GCP APIs without downloading key files, IAM impersonation permissions must first be granted via the Service Account Token Creator role on the target service account. The developer then logs in with user credentials using gcloud auth login. Next, Application Default Credentials (ADC) are configured with impersonation via gcloud auth application-default login --impersonate-service-account. Finally, the Python application code initializes Google Cloud Client Libraries using standard ADC detection, executing securely under the target service account identity.
Step-by-Step Solution
Key Concept
Application Default Credentials (ADC) with Service Account Impersonation
Estimated Time:2m 0s