Skip to content

Instantly share code, notes, and snippets.

@jcrqr
Last active July 6, 2022 13:00
Show Gist options
  • Save jcrqr/710d050f45a1d834addbd64aed52f1b6 to your computer and use it in GitHub Desktop.
Save jcrqr/710d050f45a1d834addbd64aed52f1b6 to your computer and use it in GitHub Desktop.
Read parameters from AWS SSM specified in a properties file and replace the keys in a configuration file with the parameter values
{
"foo": BAR
}
#! /bin/bash
aws ssm get-parameters --names $(awk -F "=" '{ print $2 }' secret.properties | paste -s -d " " -) --with-decryption \
| jq '.Parameters[] | "s~\(.Name)~\"\(.Value)\"~"' | jq -rs '. | join(";")' \
| { read re; sed -e "$re" secret.properties; } \
| awk -F "=" '{ print "s~" $1 "~" $2 "~g" }' | paste -s -d "; " - \
| { read re; sed -e "$re" config.json; }
BAR=/my/secret/param
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment