Skip to content

Commit 92ed915

Browse files
committed
opsmode handling for ops container
1 parent f4f445a commit 92ed915

3 files changed

Lines changed: 24 additions & 40 deletions

File tree

mrt-inttest-services/merritt-ops/scripts/merritt-mysql-write.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.

mrt-inttest-services/merritt-ops/scripts/merritt-mysql.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ DBUSER=user
55
DBPASS=password
66
DBDATABASE=inv
77

8+
if [[ "OPS_MODE" == "readwrite" ]]
9+
then
10+
OPSMODE_PARAM="readwrite"
11+
else
12+
OPSMODE_PARAM="readonly"
13+
fi
14+
815
if [[ "$MERRITT_ECS" == "ecs-dev" ]]
916
then
1017
# for dev environments, readonly credentials are not needed
@@ -20,13 +27,13 @@ then
2027
elif [[ "$MERRITT_ECS" == "ecs-stg" ]]
2128
then
2229
DBHOST=$(aws ssm get-parameter --name /uc3/mrt/stg/inv/db-host --query Parameter.Value --output text)
23-
DBUSER=$(aws ssm get-parameter --name /uc3/mrt/stg/inv/readonly/db-user --query Parameter.Value --output text)
24-
DBPASS=$(aws ssm get-parameter --name /uc3/mrt/stg/inv/readonly/db-password --query Parameter.Value --with-decryption --output text)
30+
DBUSER=$(aws ssm get-parameter --name /uc3/mrt/stg/inv/${OPSMODE_PARAM}/db-user --query Parameter.Value --output text)
31+
DBPASS=$(aws ssm get-parameter --name /uc3/mrt/stg/inv/${OPSMODE_PARAM}/db-password --query Parameter.Value --with-decryption --output text)
2532
elif [[ "$MERRITT_ECS" == "ecs-prd" ]]
2633
then
2734
DBHOST=$(aws ssm get-parameter --name /uc3/mrt/prd/inv/db-host --query Parameter.Value --output text)
28-
DBUSER=$(aws ssm get-parameter --name /uc3/mrt/prd/inv/readonly/db-user --query Parameter.Value --output text)
29-
DBPASS=$(aws ssm get-parameter --name /uc3/mrt/prd/inv/readonly/db-password --query Parameter.Value --with-decryption --output text)
35+
DBUSER=$(aws ssm get-parameter --name /uc3/mrt/prd/inv/${OPSMODE_PARAM}/db-user --query Parameter.Value --output text)
36+
DBPASS=$(aws ssm get-parameter --name /uc3/mrt/prd/inv/${OPSMODE_PARAM}/db-password --query Parameter.Value --with-decryption --output text)
3037
fi
3138

3239
mysql -h $DBHOST -u $DBUSER --password=$DBPASS --database=$DBDATABASE "$@"

mrt-inttest-services/merritt-ops/scripts/set-credentials.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,31 @@ if [[ -z $SSM_ROOT_PATH ]]; then
55
exit 1
66
fi
77

8-
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}cloud/nodes/wasabi-accessKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
8+
if [[ "OPS_MODE" == "readwrite" ]]
9+
then
10+
OPSMODE_PARAM="cloud"
11+
else
12+
OPSMODE_PARAM="cloud-readonly"
13+
fi
14+
15+
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}${OPSMODE_PARAM}/nodes/wasabi-accessKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
916
sed -i -e "s|TEMPLATE_WASABI_ACCESS_KEY_ID|$ssmval|" /root/.aws/credentials
10-
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}cloud/nodes/wasabi-secretKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
17+
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}${OPSMODE_PARAM}/nodes/wasabi-secretKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
1118
sed -i -e "s|TEMPLATE_WASABI_SECRET_ACCESS_KEY|$ssmval|" /root/.aws/credentials
1219
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}cloud/nodes/wasabi-endpoint --query Parameter.Value --output text || echo not_applicable)
1320
sed -i -e "s|TEMPLATE_WASABI_ENDPOINT_URL|$ssmval|" /root/.aws/config
1421

15-
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}cloud/nodes/sdsc-accessKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
22+
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}${OPSMODE_PARAM}/nodes/sdsc-accessKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
1623
sed -i -e "s|TEMPLATE_SDSC_ACCESS_KEY_ID|$ssmval|" /root/.aws/credentials
17-
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}cloud/nodes/sdsc-secretKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
24+
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}${OPSMODE_PARAM}/nodes/sdsc-secretKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
1825
sed -i -e "s|TEMPLATE_SDSC_SECRET_ACCESS_KEY|$ssmval|" /root/.aws/credentials
1926
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}cloud/nodes/sdsc-endpoint --query Parameter.Value --output text || echo not_applicable)
2027
sed -i -e "s|TEMPLATE_SDSC_ENDPOINT_URL|$ssmval|" /root/.aws/config
2128

2229
# Note that these credential only exist in stage and prod... no dev keys exist
23-
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}cloud/nodes/sdsc-s3-accessKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
30+
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}${OPSMODE_PARAM}/nodes/sdsc-s3-accessKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
2431
sed -i -e "s|TEMPLATE_SDSC_S3_ACCESS_KEY_ID|$ssmval|" /root/.aws/credentials
25-
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}cloud/nodes/sdsc-s3-secretKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
32+
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}${OPSMODE_PARAM}/nodes/sdsc-s3-secretKey --with-decryption --query Parameter.Value --output text || echo not_applicable)
2633
sed -i -e "s|TEMPLATE_SDSC_S3_SECRET_ACCESS_KEY|$ssmval|" /root/.aws/credentials
2734
ssmval=$(aws ssm get-parameter --name ${SSM_ROOT_PATH}cloud/nodes/sdsc-s3-endpoint --query Parameter.Value --output text || echo not_applicable)
2835
sed -i -e "s|TEMPLATE_SDSC_S3_ENDPOINT_URL|$ssmval|" /root/.aws/config

0 commit comments

Comments
 (0)