Skip to content

Commit

Permalink
feat: skip missing params
Browse files Browse the repository at this point in the history
  • Loading branch information
harishv7 committed Sep 20, 2023
1 parent 44007af commit 82845d0
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions .platform/hooks/predeploy/06_fetch_ssm_parameters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ENV_VARS=(
"DD_AGENT_MAJOR_VERSION"
"DD_ENV"
"DD_LOGS_INJECTION"
"TEST_VAR3"
"DD_SERVICE"
"DD_TAGS"
"DD_TRACE_STARTUP_LOGS"
Expand Down Expand Up @@ -85,20 +86,25 @@ ENV_VARS=(
echo "Set AWS region"
aws configure set default.region ap-southeast-1

set +e # Do not exit if a command fails

for ENV_VAR in "${ENV_VARS[@]}"; do
echo "Fetching ${ENV_VAR} from SSM"

VALUE=$(aws ssm get-parameter --name "${ENV_TYPE}_${ENV_VAR}" --with-decryption --query "Parameter.Value" --output text 2>/dev/null)

if [ $? -ne 0 ]; then
echo "Failed to fetch ${ENV_VAR}. Skipping."
continue
fi

echo "${ENV_VAR}=${VALUE}" >> /tmp/isomer/.isomer.env
echo "Saved ${ENV_VAR}"
echo "Fetching ${ENV_VAR} from SSM"

VALUE=$(aws ssm get-parameter --name "${ENV_TYPE}_${ENV_VAR}" --with-decryption --query "Parameter.Value" --output text 2>/dev/null)
STATUS=$? # Capture exit status of the aws ssm command

if [ $STATUS -ne 0 ]; then
echo "Failed to fetch ${ENV_VAR}. Skipping."
continue
fi

echo "${ENV_VAR}=${VALUE}" >> /tmp/isomer/.isomer.env
echo "Saved ${ENV_VAR}"
done

set -e # Exit on command failure from this point onwards

# Use flock to ensure that the EFS file is locked during the copy operation
(
flock -n 200 || exit 1
Expand Down

0 comments on commit 82845d0

Please sign in to comment.