Skip to content

Instantly share code, notes, and snippets.

@treacher
Created September 17, 2017 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treacher/9b8c78529fd7c4506230f51eff8495a6 to your computer and use it in GitHub Desktop.
Save treacher/9b8c78529fd7c4506230f51eff8495a6 to your computer and use it in GitHub Desktop.
#!/bin/bash
file_location=$1
kms_key=$2
display_usage() {
echo "Usage: $0 <file-with-secrets> <kms-key-alias>"
exit 1
}
if [ $# -le 1 ]; then
display_usage
fi
while IFS= read -r line
do
variable=$(echo $line | cut -f 1 -d =)
value=$(echo $line | cut -f 2 -d =)
if type shush >/dev/null 2>&1 eq 0; then
encrypted_value=$(shush encrypt $kms_key $value)
echo "KMS_ENCRYPTED_$variable: \"$encrypted_value\""
else
echo "Shush is not installed, please install it via: https://github.com/realestate-com-au/shush"
fi
done < $file_location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment