Multiple configurations

Oftentimes, development and operations work in GCP will involve frequently switching between Google Cloud projects, user accounts, and service accounts. Many times these jumps between workflows will also involve working with different regions and zones, deployment strategies, and so on. For example, when deploying an App Engine application to a lower life cycle, it may be ideal to automatically promote the service to receive all traffic. This is probably not the desired behavior for higher life cycles where procedures like smoke testing need to take place. A user could go about updating every related configuration property to better suit the new context. But that would be tedious and error-prone.

For these kinds of situations, the Google Cloud SDK includes support for separate configurations. A configuration is an isolated set of configuration properties, and the Google Cloud SDK tools are able to switch between configurations as the user wills. We provisioned our first configuration, default, when running gcloud init.

You can create any number of additional configurations either by rerunning gcloud init or by running gcloud config configurations create <NAME>. For managing and switching between configurations, use the gcloud config configurations command group. To switch between configurations, use gcloud config configurations activate <CONFIGURATION>.

Any property set in one configuration will not affect properties in others, providing an easy way for defining distinct working contexts. To modify a value across all configurations, gcloud supports an optional --installation flag. For example, if you're behind a corporate proxy and the address changes, you could run gcloud config set proxy/address <new address> --installation to avoid updating each configuration independently.

Much like we can pass the --project global flag to any gcloud command to override the target project, gcloud also accepts the global --configuration flag. This can be extremely powerful as it allows users to execute a single command with the full configuration context. Aside from user defined configurations, the Google Cloud SDK contains a special NONE configuration. This configuration has no set properties, making it ideal for easily ensuring no configuration properties will affect command behavior.