LinuxCommandLibrary

gcloud-config-set

Set Google Cloud SDK configuration properties

TLDR

Set the project property in the core section

$ gcloud config set project [project_id]
copy

Set the compute zone for future operations
$ gcloud config set compute/zone [zone_name]
copy

Disable prompting to make gcloud suitable for scripting
$ gcloud config set disable_prompts true
copy

View the list of properties currently in use
$ gcloud config list
copy

Unset a previously set property
$ gcloud config unset [property_name]
copy

Create a new configuration profile
$ gcloud config configurations create [configuration_name]
copy

Switch between different configuration profiles
$ gcloud config configurations activate [configuration_name]
copy

SYNOPSIS

gcloud config set PROPERTY_NAME VALUE [--configuration=CONFIGURATION_NAME] [--unset] [--installation]

PARAMETERS

PROPERTY_NAME
    The identifier for the configuration setting to be modified (e.g., `core/project`, `compute/zone`).

VALUE
    The desired value to assign to the specified property.

--configuration=CONFIGURATION_NAME
    Applies the property change to a specific named gcloud configuration rather than the currently active one. For example, use `default`, `dev`, `prod`.

--unset
    Removes the specified property from the configuration instead of setting a new value.

--installation
    Sets the property globally for the entire gcloud installation, affecting all configurations, unless overridden by a configuration-specific setting.

DESCRIPTION

The `gcloud config set` command is a fundamental utility within the Google Cloud CLI (Command Line Interface) for managing and modifying its configuration properties. These properties dictate the default behavior of subsequent `gcloud` commands, streamlining workflows by eliminating the need to repeatedly specify common parameters like the Google Cloud project ID, compute zone, or user account.

When executed, `gcloud config set` updates the specified property within the currently active gcloud configuration. Users typically maintain multiple configurations (e.g., 'default', 'development', 'production') to easily switch between different Google Cloud environments or projects without altering their global settings.

Common properties that can be set include `core/project` (the default Google Cloud project), `core/account` (the default user account for authentication), `compute/zone` (the default compute engine zone), and `compute/region` (the default compute engine region). By setting these, `gcloud` commands automatically apply these values unless overridden by command-line flags or environment variables.

This command is crucial for establishing and maintaining a consistent development or operational environment, improving efficiency, and reducing the potential for errors associated with manual parameter entry. It plays a central role in customizing the `gcloud` CLI to fit specific user or project requirements.

CAVEATS

The command `gcloud config set` is the actual official Google Cloud CLI command for managing configuration properties. The name 'gcloud-config-set' as a standalone command is not standard within the gcloud CLI.

Changes made with `gcloud config set` persist and affect all subsequent gcloud commands run under the modified configuration. It's important to understand the property precedence: command-line flags override environment variables, which override properties in the active configuration, which in turn override installation-level properties.

CLARIFICATION ON COMMAND NAME

The command specified as 'gcloud-config-set' is not a standard `gcloud` CLI command. The correct and official command for setting Google Cloud SDK properties is `gcloud config set`. It is possible that 'gcloud-config-set' refers to a custom script, an alias, or a slight misremembering of the standard command.

PROPERTY PRECEDENCE

Understanding how gcloud resolves configuration properties is critical. Properties are resolved in a specific order: command-line flags (highest precedence) override environment variables (e.g., `CLOUDSDK_CORE_PROJECT`), which override properties set in the active gcloud configuration, which finally override properties set globally for the gcloud installation. This hierarchy determines the effective value of any given property at runtime.

HISTORY

The Google Cloud CLI, including its robust configuration system, was designed to provide a flexible and powerful interface for interacting with Google Cloud services. The `gcloud config` command group has been a core component since the early stages of the CLI's development, allowing users to manage distinct operational contexts (projects, accounts, regions) and streamline their command-line interactions. Its evolution has focused on providing granular control and easy switching between different environments, adapting to the complex needs of cloud developers and operators.

SEE ALSO

gcloud config list(1), gcloud config get(1), gcloud config configurations activate(1), gcloud auth login(1)

Copied to clipboard