Skip to content

Instantly share code, notes, and snippets.

@Slakah
Created May 14, 2018 10:20
Show Gist options
  • Save Slakah/80bf7b1bb7f213bfc6b8325847bd7e8f to your computer and use it in GitHub Desktop.
Save Slakah/80bf7b1bb7f213bfc6b8325847bd7e8f to your computer and use it in GitHub Desktop.
Convert AWS SSM parameters to environment variables, used as `eval $(./ssm-to-env.sh "<ssm-path>")`
#!/bin/bash
set -uxe
# Reads the ssm path and echos out the parameters in the form
# export NAME=some-value
readonly path=$1
exec aws --region us-east-1 ssm get-parameters-by-path --no-paginate --path $path --with-decryption --query Parameters | \
jq -r 'map("\(.Name | sub("'$path'";""))=\(.Value)") | join("\n")' | \
sed -e 's/^/export /'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment