33# Collect secrets from AWS SSM Parameter Store and
44# opt out as environment variable exports.
55
6- VERSION=' 0.0.1 '
6+ VERSION=' 0.0.2 '
77
88# Colors
99C_RESET=' \033[0m'
@@ -25,19 +25,22 @@ and output as environment variable exports"
2525 echo
2626 echo " Optional arguments:"
2727 echo " -h Show this help message and exit"
28- echo " -p Product tag (moonstream, spire, brood, drones) "
28+ echo " -n Provide true if server is Blockchain node "
2929 echo " -o Output file name environment variables export to"
30+ echo " -p Product tag (moonstream, spire, brood, drones)"
3031}
3132
3233# TODO(kompotkot): Flag for export prefix
33- product_flag =" "
34+ node_flag =" "
3435output_flag=" "
36+ product_flag=" "
3537verbose_flag=" false"
3638
37- while getopts ' p:o :v' flag; do
39+ while getopts ' no:p :v' flag; do
3840 case " ${flag} " in
39- p) product_flag= " ${OPTARG} " ;;
41+ n) node_flag= " true " ;;
4042 o) output_flag=" ${OPTARG} " ;;
43+ p) product_flag=" ${OPTARG} " ;;
4144 h) usage
4245 exit 1 ;;
4346 v) verbose_flag=" true" ;;
6366
6467verbose " ${PREFIX_INFO} Script version: v${VERSION} "
6568
69+ PARAMETER_FILTERS=" Key=tag:Product,Values=${product_flag} "
70+ if [ " ${node_flag} " == " true" ]; then
71+ verbose " ${PREFIX_INFO} Node flag provided, extracting environment variables only for nodes"
72+ PARAMETER_FILTERS=" $PARAMETER_FILTERS Key=tag:Node,Values=true"
73+ fi
74+
6675verbose " ${PREFIX_INFO} Retrieving deployment parameters with tag ${C_GREEN} Product:${product_flag}${C_RESET} "
6776ENV_PARAMETERS=$( aws ssm describe-parameters \
68- --parameter-filters Key=tag:Product,Values= ${product_flag } \
77+ --parameter-filters ${PARAMETER_FILTERS } \
6978 | jq -r .Parameters[].Name)
7079if [ -z " ${ENV_PARAMETERS} " ]; then
7180 verbose " ${PREFIX_CRIT} There no parameters for provided product tag"
0 commit comments