Last active
November 7, 2018 00:09
-
-
Save jasonbartz/d5c4e3494c28bad7664f302de6a81d60 to your computer and use it in GitHub Desktop.
simple kms cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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