Skip to content

Commit 7228b8b

Browse files
authored
Merge pull request #5 from bugout-dev/node-filter-parameters
parameters bash able to filter node env vars
2 parents 4c6567b + 8c86d4b commit 7228b8b

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

scripts/parameters.bash

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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
99
C_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=""
3435
output_flag=""
36+
product_flag=""
3537
verbose_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" ;;
@@ -63,9 +66,15 @@ fi
6366

6467
verbose "${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+
6675
verbose "${PREFIX_INFO} Retrieving deployment parameters with tag ${C_GREEN}Product:${product_flag}${C_RESET}"
6776
ENV_PARAMETERS=$(aws ssm describe-parameters \
68-
--parameter-filters Key=tag:Product,Values=${product_flag} \
77+
--parameter-filters ${PARAMETER_FILTERS} \
6978
| jq -r .Parameters[].Name)
7079
if [ -z "${ENV_PARAMETERS}" ]; then
7180
verbose "${PREFIX_CRIT} There no parameters for provided product tag"

0 commit comments

Comments
 (0)