Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Developer practice bank has an additional 608 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
You are developing a Python backend service that uses Google Cloud client libraries to listen for real-time updates in Firestore and upload large data exports to Cloud Storage. You must configure authentication across environments while meeting the following requirements:
How should you configure authentication and IAM permissions?
roles/iam.serviceAccountTokenCreator) to run gcloud auth application-default login --impersonate-service-account locally.Application Default Credentials (ADC) is an authentication strategy used by Google Cloud client libraries to automatically locate credentials based on the runtime environment. Instead of hardcoding authentication logic, developers initialize clients with default constructors, and ADC searches a predefined order of credential sources. Service account impersonation allows an authorized user to generate short-lived access tokens for a service account without creating or downloading any private key files.
roles/iam.serviceAccountTokenCreator (iam.serviceAccounts.getAccessToken permission) lets them run gcloud auth application-default login --impersonate-service-account=SERVICE_ACCT_EMAIL. This writes an impersonation configuration to the local ADC credential file, allowing Python client libraries to act with the staging service account's permissions without static keys or direct user write roles.Unlike passing explicit credential objects in code or managing static key files via GOOGLE_APPLICATION_CREDENTIALS, combining ADC with attached service accounts in production and service account impersonation locally is the recommended, key-free pattern for Python workloads running on Google Cloud.
GOOGLE_APPLICATION_CREDENTIALS environment variable to each key path, and pass the key file path to the Python client library constructors.GOOGLE_APPLICATION_CREDENTIALS DoA service account key is a downloadable JSON file containing a long-lived RSA private key that proves a service account's identity. Setting the GOOGLE_APPLICATION_CREDENTIALS environment variable points Application Default Credentials (ADC) to a credential file on disk, which is the first location ADC checks when authenticating requests.
The application were running on an on-premises server or external cloud environment where Workload Identity Federation could not be configured, organization policy permitted downloadable keys, and ADC relied on GOOGLE_APPLICATION_CREDENTIALS without hardcoding key paths in application code.
While GOOGLE_APPLICATION_CREDENTIALS is valid for pointing ADC to Workload Identity Federation configuration files outside Google Cloud, using it with static service account keys inside Google Cloud environments is an anti-pattern.
service_account.Credentials.from_service_account_info inside the Python code for Compute Engine VMs, and have developers run gcloud auth application-default login locally after being granted the Service Usage Consumer role (roles/serviceusage.serviceUsageConsumer).from_service_account_info and roles/serviceusage.serviceUsageConsumer DoThe service_account.Credentials.from_service_account_info method initializes a Google Cloud client library with an in-memory dictionary containing service account private key fields. The Service Usage Consumer role (roles/serviceusage.serviceUsageConsumer) grants the serviceusage.services.use permission, allowing a principal to make API calls billed to a quota project.
from_service_account_info still depends on static service account key material, violating the organization policy prohibiting service account keys and exposing private key fields in configuration streams or code.gcloud auth application-default login without impersonation authenticates developers with their personal user credentials. Because organization policy restricts user accounts from direct write access to staging datastores, and roles/serviceusage.serviceUsageConsumer grants no Firestore or Cloud Storage data permissions, local write tests will fail.credentials object overrides Application Default Credentials.roles/serviceusage.serviceUsageConsumer only enables quota project usage and does not authorize reading Firestore documents or writing Cloud Storage objects.An application had a strict requirement to dynamically load externally sourced service account keys from an in-memory secret vault rather than using ADC, and developers were permitted to write directly to staging using their own user accounts.
gcloud config set auth/impersonate_service_account so the Python client libraries automatically impersonate the staging service account, and run gcloud auth application-default login on the Compute Engine VMs to store production credentials.gcloud config set and gcloud auth application-default login DoThe gcloud config set auth/impersonate_service_account command configures the Google Cloud CLI (gcloud) to impersonate a target service account when running CLI commands. Separately, gcloud auth application-default login is a CLI command that creates a local Application Default Credentials (ADC) JSON file on a workstation for use by client libraries and third-party tools.
gcloud CLI are completely distinct from ADC. Running gcloud config set auth/impersonate_service_account affects gcloud CLI commands, not Python client libraries. For Python client libraries to impersonate a service account via ADC, developers must pass --impersonate-service-account directly to gcloud auth application-default login.gcloud auth application-default login on a production Compute Engine VM requires interactive browser sign-in and stores user-linked credentials on disk rather than using an attached service account.gcloud CLI configurations and local ADC credential files (application_default_credentials.json) do not share impersonation settings automatically.gcloud auth application-default login is designed specifically for local development workstations, not headless production servers.GOOGLE_APPLICATION_CREDENTIALS, then the local application_default_credentials.json file, and finally the metadata server for an attached service account.Developers were only running gcloud CLI commands locally (rather than Python client libraries) and were not trying to use gcloud auth application-default login on production VMs.
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