Skip to content

Instantly share code, notes, and snippets.

@bholzer
Created March 15, 2020 05:51
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 bholzer/53ec9d3ebc6a72e502b651b65447ced6 to your computer and use it in GitHub Desktop.
Save bholzer/53ec9d3ebc6a72e502b651b65447ced6 to your computer and use it in GitHub Desktop.
Fetch and set environment variables from AWS systems manager param store.
#!/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