Created
March 15, 2020 05:51
-
-
Save bholzer/53ec9d3ebc6a72e502b651b65447ced6 to your computer and use it in GitHub Desktop.
Fetch and set environment variables from AWS systems manager param store.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
params=$(aws ssm get-parameters-by-path --region $REGION --with-decryption --path "/path/to/variable" --recursive) | |
for param in $(echo $params | jq -r ".Parameters[] | @base64"); do | |
ORIG_IFS=$IFS | |
IFS="/" | |
full_name=$(echo $param | base64 --decode | jq -r ".Name") | |
read -ra name_components <<< "$full_name" | |
IFS=$ORIG_IFS | |
var_name=${name_components[-1]} | |
printf -v $var_name $(echo $param | base64 --decode | jq -r ".Value") | |
export $var_name | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment