Skip to content

Instantly share code, notes, and snippets.

@Kshitiz1403
Forked from jzwiep/load_ssm_params.sh
Created August 26, 2024 16:30
Show Gist options
  • Save Kshitiz1403/4b1ff0dd6b2eba3e86da11622575cfd2 to your computer and use it in GitHub Desktop.
Save Kshitiz1403/4b1ff0dd6b2eba3e86da11622575cfd2 to your computer and use it in GitHub Desktop.
Load all SSM parameters on a path into your environment
PARAMS_LIST=$(aws ssm get-parameters-by-path \
--path "/var/path/" \
--recursive \
--query 'Parameters[*].[Name, Value]' \
--output text \
--with-decryption)
# "/var/path/VARNAME variable_value" --> "export VARNAME=variable_value"
EXPORT_STATEMENTS=$(echo "$PARAMS_LIST" | awk '{ sub(".*/", "", $1); printf("export %s=\"%s\"\n", $1, $2) }')
eval "$EXPORT_STATEMENTS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment