Cloud Shell already has the
gcloud CLI pre-installed, so you can skip ahead to configure default zone and region.
To install the
gcloud CLI on your local machine, follow the official installation guide for your platform and then follow the below steps to finish configuration.
Authenticate gcloud so that it can interact with Google Cloud Platform using your account.
gcloud auth login
Set 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
API calls to Google Cloud may be rate limited and subject to quotas. The quotas are typically tied to a Google Cloud Project. When you are running the application locally, and using the Application Default Credentials, the requests need to be associated with a project to account for usage quota. Typically, the Quota Project should be the same as the project that you are currently working with. In a larger organization, it can be a Project that's used for development purposes and not the production project.
When configuring the Application Default Credentials the first time, It will also configure a Quota Project to be the same as the default project you previously configured.
If needed, you can 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