Skip to content

Instantly share code, notes, and snippets.

@donhenton
Last active July 29, 2019 15:37
Show Gist options
  • Save donhenton/fa624c7a865185dbad40440c192a5afa to your computer and use it in GitHub Desktop.
Save donhenton/fa624c7a865185dbad40440c192a5afa to your computer and use it in GitHub Desktop.
Decrypt/Encrypt Using AWS and CLI

Encryption

aws kms encrypt --key-id <kms-id> \
--profile default \
--plaintext fileb://input_file.txt \
--query CiphertextBlob \
--output text \
	| base64 --decode > output.enc

Decryption

aws kms decrypt --ciphertext-blob fileb://output.enc  \
--output text  --query Plaintext  --region us-east-2 | base64 -D > decrypted.txt

Setup

  • set up aws client via aws configure
  • user for that set up doesn't need any IAM rights, but must be assigned as a key user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment