Prepare and test your skills
Prepare and test your skills
Free sample question, answered and explained below. The Professional Cloud DevOps Engineer practice bank has 1,455 more like it. Try 10 free: instant score, no account.
Your team is building automated infrastructure management scripts in Python and Go using the official Google Cloud Client Libraries. To comply with organizational security baselines, developers are strictly prohibited from downloading, exporting, or storing long-lived service account private keys (.json key files) on their local workstations.
Developers have already been granted the Service Account Token Creator (roles/iam.serviceAccountTokenCreator) role on the workload service account sa-orchestrator@company-project.iam.gserviceaccount.com.
How should developers configure their local development environments so that the client library scripts authenticate as the service account via Application Default Credentials (ADC) without using exported key files?
gcloud auth print-access-token and store the token string directly in a file pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable.The command gcloud auth print-access-token outputs an OAuth 2.0 Bearer access token string intended for authenticating direct HTTP/REST requests (such as curl commands).
GOOGLE_APPLICATION_CREDENTIALS environment variable expects the file path to a structured JSON credential file (such as an authorized user credential, service account key, or external account credential), not a raw access token string.curl or Invoke-WebRequest.The developer was making a one-off REST API call using curl -H "Authorization: Bearer $(gcloud auth print-access-token)" rather than building automated scripts with client libraries.
gcloud auth application-default login --impersonate-service-account=sa-orchestrator@company-project.iam.gserviceaccount.com.Service account impersonation configured through Application Default Credentials (ADC) allows developers and client libraries to obtain short-lived credentials by assuming the identity and permissions of a target service account at runtime without downloading static private keys.
gcloud auth application-default login --impersonate-service-account acquires credentials dynamically via IAM token generation APIs rather than creating permanent .json key files on disk.roles/iam.serviceAccountTokenCreator permission, ensuring all operations are fully auditable in Cloud Audit Logs.storage.NewClient(ctx) in Go or storage.Client() in Python) works identically in local development and production environments.This method is the Google-recommended best practice for local development when testing scripts that require service account permissions. It directly populates the standard local ADC credential file with impersonation configuration recognized by supported client libraries.
gcloud config set auth/impersonate_service_account sa-orchestrator@company-project.iam.gserviceaccount.com.Running gcloud config set auth/impersonate_service_account configures the Google Cloud CLI (gcloud) property to impersonate the specified service account when executing CLI commands.
auth/impersonate_service_account property modifies only the gcloud CLI profile configuration. It does not generate or update the local ADC file (~/.config/gcloud/application_default_credentials.json).gcloud CLI property settings. Consequently, the script will either fail with authentication errors or fall back to user credentials.gcloud command-line tool, not programmatic SDKs or client libraries.The requirement was specifically to execute ad-hoc administrative commands through the gcloud CLI tool (such as gcloud compute instances list) under the assumed service account identity.
gcloud iam service-accounts keys create key.json --iam-account=sa-orchestrator@company-project.iam.gserviceaccount.com and set the GOOGLE_APPLICATION_CREDENTIALS environment variable to key.json.This command generates a static, user-managed RSA private key file (.json) for the service account and points the GOOGLE_APPLICATION_CREDENTIALS environment variable to the generated file.
The workload was running on legacy on-premises infrastructure that lacked internet access to STS/IAM APIs and could not support Workload Identity Federation or short-lived token exchange.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated