Skip to content

Instantly share code, notes, and snippets.

@nshttpd
Created August 1, 2017 12:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nshttpd/58de3e76d479b0576eaccb4e9cb9ac5c to your computer and use it in GitHub Desktop.
Save nshttpd/58de3e76d479b0576eaccb4e9cb9ac5c to your computer and use it in GitHub Desktop.
gcloud decrypt
#!/bin/bash
set -e
GCP_PROJECT="${GCP_PROJECT:-default}"
KMS_KEYRING="${KMS_KEYRING:-default}"
KMS_LOCATION="${KMS_LOCATION:-default}"
KMS_KEY="${KMS_KEY:-default}"
hash gcloud 2>/dev/null || { echo >&2 "glcoud command required to decrypt secrets."; exit 1; }
echo "Decrypting : $1"
gcloud kms decrypt --ciphertext-file=$1 --plaintext-file=${1%.enc} --key=${KMS_KEY} --keyring=${KMS_KEYRING} --location=${KMS_LOCATION}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment