This page shows you how to initialize the Google Cloud SDK.
After you install Cloud SDK, the next step is typically run the
gcloud init command to perform initial setup
tasks. You can also run gcloud init at a later time to change your settings or
create a new configuration.
gcloud init performs the following setup steps:
- Authorizes Cloud SDK tools to use your user account credentials to access Google Cloud, or lets you select an account if you have previously authorized access
- Sets up a Cloud SDK configuration and sets a base set of properties, including the active account from the step above, the current project, and if applicable, the default Google Compute Engine region and zone
You can run the following as alternatives to gcloud init:
| Command | Description |
|---|---|
gcloud auth login
|
Authorize with a user account without setting up a configuration. |
gcloud auth activate-service-account
|
Authorize with a service account instead of a user account. Useful for authorizing non-interactively and without a web browser. |
gcloud config [COMMAND]
gcloud config configurations [COMMAND]
|
Create and manage Cloud SDK configurations and properties. |
Run gcloud init
To initialize Cloud SDK:
Run
gcloud init:gcloud initIf you are in a remote terminal session, you can use the
--console-onlyflag to prevent the command from launching a browser-based authorization flow, if required:gcloud init --console-onlyCreate or select a configuration if prompted.
If you are initializing a new Cloud SDK installation,
gcloud initcreates a new one nameddefaultfor you and sets it as the active configuration. If you have existing configurations,gcloud initprompts you to choose between three options — re-initialize the active one, switch to another one and re-initialize it, or create a new one.Complete the authorization step when prompted.
Depending on whether you have previously authorized access to Google Cloud, you may be prompted to log in and grant access in a web browser, or to select an existing account.
If you used the
--console-onlyflag and login is required, you must then cut and paste the provided authorization URL into another browser window and follow the prompts provided.When this step is completed,
gcloud initsets theaccountproperty in the configuration to the specified account.Choose a current Google Cloud project if prompted.
If you only have access to one project, including the default project for your user account,
gcloud initselects it for you.Otherwise, you can select a project from a list of projects for which you have Owner, Editor or Viewer permissions.
gcloud initsets theprojectproperty in the configuration to the property you choose. If you have access to more than 200 projects, you will be prompted to enter a project id, create a new project, or list projects.This account has a lot of projects! Listing them all can take a while. [1] Enter a project ID [2] Create a new project [3] List projects Please enter your numeric choice:
Choose a default Google Compute Engine zone if prompted.
If you do not have the Compute Engine API enabled or you already have a default zone in your project-level metadata, you will not see this step.
gcloud initsets theregionandzoneproperties in the configuration using the zone you choose.
When gcloud init finishes, it prints the properties in the active
configuration to the terminal:
[compute] region = us-east1 zone = us-east1-b [core] account = user@google.com disable_usage_reporting = False project = example-project
You can view these properties at any other time using the
gcloud config list command.
What's next
- Read Authorizing Cloud SDK tools to learn more about tool authorization.
- Read Cloud SDK Configurations to learn more about configurations.
- Read Cloud SDK Properties to learn more about configurations.