Skip to content

Instantly share code, notes, and snippets.

@jasonbartz
Last active November 7, 2018 00:09
Show Gist options
  • Save jasonbartz/d5c4e3494c28bad7664f302de6a81d60 to your computer and use it in GitHub Desktop.
Save jasonbartz/d5c4e3494c28bad7664f302de6a81d60 to your computer and use it in GitHub Desktop.
simple kms cli
#!/bin/bash
PROFILE=""
if [ -z "$AWS_PROFILE" ]; then
PROFILE="--profile $AWS_PROFILE"
fi
case $1 in
encrypt)
aws kms encrypt ${PROFILE} --key-id $2 --plaintext $3 --output text --query CiphertextBlob
;;
decrypt)
aws kms decrypt ${PROFILE} --ciphertext-blob fileb://<(echo $2 | base64 -D) --output text --query Plaintext | base64 -D
;;
decrypt-raw)
aws kms decrypt ${PROFILE} --ciphertext-blob fileb://<(echo $2 | base64 -D)
;;
*)
echo $"Usage: $0 {encrypt|decrypt}"
exit 1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment