Get Your CertGoogle Cloud Associate Cloud EngineerPlayCompete
‹ All Google Cloud Associate Cloud Engineer questions

GCP Associate Cloud Engineer Practice Question 12: gcloud Named Configurations

Google Cloud Associate Cloud Engineer · Test 2 · question 2 of 10

gcloud CLIeasy

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?

Select one answer
Show answer and explanation

Answer:

  • D. Create a named gcloud configuration for each context and switch with gcloud config configurations activate

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

Practice Test 2 ›

Study guides for Google Cloud Associate Cloud Engineer