Skip to content

Instantly share code, notes, and snippets.

@pasali
Last active May 21, 2020 05:50
Show Gist options
  • Save pasali/56d8248fad8fbcc47ab6a8d797e74cf5 to your computer and use it in GitHub Desktop.
Save pasali/56d8248fad8fbcc47ab6a8d797e74cf5 to your computer and use it in GitHub Desktop.
AWS SSM update encryption key of secret
#!/usr/bin/env bash
keys=$(aws ssm get-parameters-by-path --path "/prod" --with-decryption | jq --raw-output '.Parameters[] | {name: .Name, value: .Value} | @base64')
for k in $keys; do
key="$(echo "$k" | base64 --decode)"
name=$(echo "$key" | jq --raw-output '.name')
value=$(echo "$key" | jq --raw-output '.value')
echo $name
aws ssm put-parameter --overwrite --name ${name} --type "SecureString" --value "${value}" --key-id "alias/custom/ssm"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment