GCP Associate Cloud Engineer Practice Question 12: gcloud Named Configurations
Google Cloud Associate Cloud Engineer · Test 2 · question 2 of 10
You work on a development project with your corporate account and on a customer's production project with a separate account. You keep running commands against the wrong project because you forget to run gcloud config set project and gcloud auth login when you switch.
What is the most efficient way to switch between the two contexts safely?
Show answer and explanation
Answer:
A gcloud named configuration bundles the active account, project, and default region and zone. Create one with gcloud config configurations create prod, set its properties once, and switch with gcloud config configurations activate prod. gcloud config configurations list shows which one is active.
Option A is unnecessary; a single installation supports any number of configurations. Option B is error prone (forgetting the flag reintroduces the mistake) and forces repeated logins. Option C pins one project for every shell session, which does not help you switch, and it takes precedence over the configuration you think is active.
Reference: Managing gcloud CLI configurations