Skip to content

Google Cloud SDK

Google account

To work with anything Google, you’ll need a Google account. The easiest way to obtain it is to signup here and make sure you choose: Use my current email address instead, so you can fill in your @d-centralize.nl email account instead of creating a new @gmail.com as the form suggests.

SDK installation

Google App Engine is now included in the Google Cloud SDK.

To install it, simply run the following commands:

Terminal window
echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install \
google-cloud-sdk

Connect the SDK to the Google cloud using your @d-centralize.nl email account:

Terminal window
gcloud auth login

Configurations

GCloud conveniently supports the use of multiple configurations. These configurations can be viewed using:

Terminal window
gcloud config configurations list

To prevent weird behavior, never set a default configuration. You’re fine if you just installed the SDK from scratch, but if you at some point have a default configuration, it can be reset using:

Terminal window
rm ~/.config/gcloud/active_config
rm ~/.config/gcloud/configurations/config_default

Database

If you’re connecting to a SQL database hosted in a cloud, you most probably need to whitelist your IP, or (in case of Google), install and use a proxy to connect through a Unix socket:

Terminal window
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
# Or, for macOS:
wget https://dl.google.com/cloudsql/cloud_sql_proxy.darwin.amd64 -O cloud_sql_proxy
chmod +x cloud_sql_proxy
./cloud_sql_proxy -projects "<GAE project>" -dir=/tmp # like: itsl-staging

You need Cloud SQL Client and Cloud SQL Viewer permissions in the GAE project the SQL database is running.

Your connection string (for use in PGAdmin for example, see Database) would have the following syntax: /tmp/itsl-staging:europe-west4:its-shared-staging.

The connection string from within a Google deployed application would be starting with /cloudsql.