Created
March 15, 2022 08:57
-
-
Save keksipurkki/33a67ce1214c1cba575e33d25b5e1e5e to your computer and use it in GitHub Desktop.
SSM parameters to .env file
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/sh | |
set -e | |
function usage() | |
{ | |
echo "Usage: $(basename $0) PATH" | |
} | |
function to_env() | |
{ | |
local prefix=$1 | |
jq -r '"\(.Name)=\(.Value)"' | sed -e "s#$prefix##" | |
} | |
function ssm_parameters() | |
{ | |
aws ssm get-parameters-by-path \ | |
--region eu-central-1 \ | |
--path $path \ | |
--with-decryption \ | |
--recursive | |
} | |
function main() | |
{ | |
local path=$1 | |
if [[ -z "$path" ]]; then | |
usage | |
exit 1 | |
fi | |
ssm_parameters $AWS_PROFILE | jq .Parameters[] | to_env $path/ | |
} | |
main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment