Google Associate Cloud EngineerSetting up a cloud solution environmentMedium

A team of developers frequently switches between multiple Google Cloud projects for different environments (development, staging, production) from their local Cloud SDK installation. They want to avoid repeatedly specifying the project ID with every command. Which 'gcloud config' command should they use to set a temporary default project for their current terminal session?

  1. Agcloud config list --filter='project'
  2. Bgcloud config configurations activate [CONFIG_NAME]
  3. Cgcloud config set project [PROJECT_ID]
  4. Dgcloud config unset project
Show answer & explanation

Correct answer: C. gcloud config set project [PROJECT_ID]

The 'gcloud config set project [PROJECT_ID]' command sets the default project for the current active configuration, which typically applies to the current terminal session unless explicitly changed or a different configuration is activated.

Why the other options are wrong

  • A. This command lists configuration properties, it doesn't set anything.
  • B. This command activates an entire named configuration, not just sets a project within the current one.
  • D. This command removes the project setting, which is the opposite of what is needed.

gcloud config set project

The `gcloud config set project [PROJECT_ID]` command sets the default Google Cloud project for the active Cloud SDK configuration, allowing subsequent commands to operate within that project without explicit specification.

  • Applies to the active configuration.
  • Can be overridden by `--project` flag.
  • Useful for quickly switching working contexts.

Memory trick: Configure your gcloud path, then target your project.

More Setting up a cloud solution environment questions