Skip to content

Instantly share code, notes, and snippets.

@pokle
Created June 29, 2016 11:56
Show Gist options
  • Save pokle/3ba7d08cf7d3c34186791544a78d9f56 to your computer and use it in GitHub Desktop.
Save pokle/3ba7d08cf7d3c34186791544a78d9f56 to your computer and use it in GitHub Desktop.
How to encrypt / decrypt an Amazon KMS secret
#!/usr/bin/env bash
KEYID=f0f2af05-6530-4dcf-a7ef-602f5bb8f642
echo hello hello > ExamplePlaintextFile
aws kms encrypt --key-id f0f2af05-6530-4dcf-a7ef-602f5bb8f642 --plaintext fileb://ExamplePlaintextFile --output text --query CiphertextBlob | base64 --decode > ExampleEncryptedFile
aws kms decrypt --ciphertext-blob fileb://ExampleEncryptedFile --output text --query Plaintext | base64 --decode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment