Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2251 from opengovsg/release-1.77
Release 1.77
- Loading branch information
Showing
21 changed files
with
771 additions
and
38 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# loads SGID environment variables to a .env file from SSM | ||
|
||
commands: | ||
01-create-env: | ||
command: "/tmp/create-env.sh" | ||
|
||
files: | ||
"/tmp/create-env.sh": | ||
mode: "000755" | ||
content : | | ||
#!/bin/bash | ||
ENV_NAME=$(/opt/elasticbeanstalk/bin/get-config environment -k SSM_PREFIX) | ||
|
||
ENV_VARS=("SGID_CLIENT_ID" "SGID_CLIENT_SECRET" "SGID_PRIVATE_KEY") | ||
|
||
echo "Set AWS region" | ||
aws configure set default.region ap-southeast-1 | ||
|
||
TARGET_DIR=/etc/gogovsg | ||
|
||
echo "Checking if ${TARGET_DIR} exists..." | ||
if [ ! -d ${TARGET_DIR} ]; then | ||
echo "Creating directory ${TARGET_DIR} ..." | ||
mkdir -p ${TARGET_DIR} | ||
if [ $? -ne 0 ]; then | ||
echo 'ERROR: Directory creation failed!' | ||
exit 1 | ||
fi | ||
else | ||
echo "Directory ${TARGET_DIR} already exists!" | ||
fi | ||
|
||
echo "Creating config for ${ENV_NAME} in ${AWS_REGION}" | ||
|
||
for ENV_VAR in "${ENV_VARS[@]}"; do | ||
echo "Running for this ${ENV_NAME}" | ||
echo "Fetching ${ENV_VAR} from SSM" | ||
VALUE=$(aws ssm get-parameter --name "${ENV_NAME}_${ENV_VAR}" --with-decryption --query "Parameter.Value" --output text) | ||
echo "${ENV_VAR}=${VALUE}" >> $TARGET_DIR/.env | ||
echo "Saved ${ENV_VAR}" | ||
done |
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
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
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
Oops, something went wrong.