Cloud Shell already has the
gcloud CLI pre-installed. Jump to the last section to configure default zone and region so you do not need to repeatedly specify it.
If you want to install on your local machine, follow the official gcloud installation guide for your platform.
gcloud CLI is installed, follow the below steps to finish configuration.
Authenticate gcloud so that it can interact with Google Cloud Platform using your account.
gcloud auth login
Configure the default project ID to your project.
gcloud config set project YOUR_PROJECT_ID
In addition to authenticating gcloud, also authenticate Application Default Credentials (ADC). ADC is used by your application/microservices during local development to authenticate with cloud services.
gcloud auth application-default login
It will also configure a Quota Project to be the same as the default project you previously configured. If needed, you configure a different Quota Project:
gcloud auth application-default set-quota-project YOUR_PROJECT_ID
This will store the credential (OAuth refresh token) in a well-known location, such as
~/.config/gcloud/application_default_credentials.json. Google Cloud client libraries can automatically detect this file and use this credential.
A cloud resource can be Zonal, Regional, or Multi-Regional. For example, a VM is Zonal, because it can only live in a single availability zone. App Engine service is regional, because it's automatically distributed across multiple zones within a single Region. Cloud Storage can store your data in a Regional bucket, or a Multi-Regional bucket.
You can always specify the
region with each of the
gcloud command. If you primarily operate within a single zone or region, set the default
zone and default
gcloud config set compute/region us-central1gcloud config set compute/zone us-central1-cgcloud config set run/region us-central1