Created
March 9, 2018 02:41
-
-
Save geraldstanje/83501d0c5cc730715e58dea5568f1a8f to your computer and use it in GitHub Desktop.
kms encrypt decrypt
This file contains hidden or 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
#!/usr/bin/env bash | |
if [ -z ${KMS_KEY_ID} ]; then | |
echo "KMS_KEY_ID unset! Exiting"; | |
exit 1 | |
fi | |
aws kms encrypt --key-id $KMS_KEY_ID --plaintext "hello" --output text --query CiphertextBlob > output.kms.yml | |
encrypted=$(<output.kms.yml) | |
echo "Encrypted: $encrypted" | |
echo "Decrypted: $(aws kms decrypt --ciphertext-blob fileb://<(echo $encrypted | base64 -D) --query Plaintext --output text | base64 -D)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
make sure aws uses us-east-1 region