Skip to content

Instantly share code, notes, and snippets.

@palnabarun
Created May 8, 2020 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palnabarun/dcfc6f0259cc4e0e03926f92c5d637a1 to your computer and use it in GitHub Desktop.
Save palnabarun/dcfc6f0259cc4e0e03926f92c5d637a1 to your computer and use it in GitHub Desktop.
switch_gcp () {
if [ -z $1 ]
then
echo "No profile name passed."
exit 1
fi
GCP_CRED_HOME=$HOME/.gcloud_credentials
GCP_CRED_FILE=$GCP_CRED_HOME/$1.json
if [ ! -f $GCP_CRED_FILE ]
then
echo "Profile " $1 "not found."
exit 1
fi
if ! gcloud config configurations describe $1
then
echo "Profie " $1 "not configured in gcloud."
exit 1
fi
export GOOGLE_CREDENTIALS=$GCP_CRED_FILE
gcloud config configurations activate $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment