Skip to content

Instantly share code, notes, and snippets.

@ivawzh
Last active February 26, 2017 07:40
Show Gist options
  • Save ivawzh/a57cf4056be7889677f8de72042e07ae to your computer and use it in GitHub Desktop.
Save ivawzh/a57cf4056be7889677f8de72042e07ae to your computer and use it in GitHub Desktop.
Bash helper function that decrypts Base64 encoded KMS secret.
function decrypt_kms {
if [ "$#" -ne 1 ]; then
echo "Please provide base64 encoded kms-secret (aka. ciphertext-blob), e.g. decrypt_kms aasd123123lkjklj"
else
echo $(aws kms decrypt \
--ciphertext-blob fileb://<(echo "$1" | base64 -d) \
--output text \
--query Plaintext | base64 --decode
)
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment