Documentation on Google Cloud SDK https://cloud.google.com/sdk/docs/ directs one to run gcloud init
after installing it.
Is there a way to automate this step given that gcloud init
is an interactive command?
One does not need to run gcloud init
. Main goal is to make sure credentials are configured and perhaps the project property is set. If you have service-account credentials, gcloud can be configured and ready to go via the following:
gcloud auth activate-service-account --key-file=credential_key.json
gcloud config set project my-project
For completeness gcloud init
essentially runs the following steps:
gcloud config configurations create my_configuration
gcloud config configurations activate my_configuration
gcloud auth login
gcloud config set account my_existing_credentials
gcloud auth activate-service-account
gcloud config set project my_project
gcloud projects list
gcloud config set compute/zone my_default_gce_zone
gcloud compute zones list
gcloud config set compute/region my_default_gce_region
gcloud compute regions list
gsutil config -n -o ~/.boto