Skip to content

Instantly share code, notes, and snippets.

@chrisdpa-tvx
Last active September 14, 2017 11:09
Show Gist options
  • Save chrisdpa-tvx/55e4f47933600bfd77a5a4a947bc4bf4 to your computer and use it in GitHub Desktop.
Save chrisdpa-tvx/55e4f47933600bfd77a5a4a947bc4bf4 to your computer and use it in GitHub Desktop.
Encrypt a file using KMS keys
aws kms create-key
# Encrypt the contents of the file
aws kms encrypt \
--key-id ${key_id_from_create_key_step} \
--plaintext fileb://super_secret_file \
--output text \
--query CiphertextBlob > super_secret_file.enc.b64
# Decrypt the contents of the file
cat super_secret_file.enc.b64 | \
base64 -D | \
aws kms decrypt --ciphertext-blob fileb:///dev/stdin --output text --query Plaintext | \
base64 -D > super_secret_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment