Skip to content

Instantly share code, notes, and snippets.

@scalp42
Forked from elblivion/kms_example.sh
Created May 22, 2017 03:48
Show Gist options
  • Save scalp42/57c974defe4f274e39d3ca531de35186 to your computer and use it in GitHub Desktop.
Save scalp42/57c974defe4f274e39d3ca531de35186 to your computer and use it in GitHub Desktop.
AWS KMS for Chef data bags
$ aws kms encrypt --key-id arn:aws:kms:us-east-1:<my_account>:key/<my_key> --plaintext $(cat ~/.chef/prod-secret) --query CiphertextBlob --output text | base64 -D > secret
$ aws kms decrypt --ciphertext-blob fileb://secret --output text --query Plaintext | base64 -D > decoded
$ if [[ "$(cat decoded)" == "$(cat ~/.chef/prod-secret)" ]]; then echo "got back original chef secret"; fi
got back original chef secret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment