Skip to content

Instantly share code, notes, and snippets.

@him229
Last active October 3, 2020 04:14
Show Gist options
  • Save him229/523ae598ebd84bc475159ebab63fb4b1 to your computer and use it in GitHub Desktop.
Save him229/523ae598ebd84bc475159ebab63fb4b1 to your computer and use it in GitHub Desktop.
if [[ -z "$CLOUDSQL_SERVICE_ACCOUNT" ]]; then
echo "Must provide CLOUDSQL_SERVICE_ACCOUNT secret." 1>&2
exit 1
fi
mkdir gcloud
cd gcloud
curl https://sdk.cloud.google.com > install.sh
bash install.sh --disable-prompts > /dev/null 2>&1
source /root/google-cloud-sdk/completion.bash.inc
source /root/google-cloud-sdk/path.bash.inc
echo "${CLOUDSQL_SERVICE_ACCOUNT}" | base64 -d > ./cred.json
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
chmod +x cloud_sql_proxy
./cloud_sql_proxy -instances=himank-jay:us-central1:reploy-sql=tcp:3306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment