Skip to content

Commit 9d35fc7

Browse files
authored
Merge pull request #23 from aws-samples/script-fix
fix:aws cli command handling for re-provisioing
2 parents 7199675 + c9a6cfe commit 9d35fc7

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

scripts/install.sh

+24-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash -e
1+
#!/bin/bash
22

33
export CDK_PARAM_SYSTEM_ADMIN_EMAIL="$1"
44

@@ -72,25 +72,34 @@ export CDK_PARAM_TIER='basic'
7272
export CDK_PARAM_STAGE='prod'
7373

7474
export CDK_BASIC_CLUSTER="$CDK_PARAM_STAGE-$CDK_PARAM_TIER"
75-
SERVICES=$(aws ecs list-services --cluster $CDK_BASIC_CLUSTER --query 'serviceArns[*]' --output text)
76-
for SERVICE in $SERVICES; do
77-
SERVICE_NAME=$(echo $SERVICE | rev | cut -d '/' -f 1 | rev)
78-
79-
echo -n "==== Service Connect Disable: "
80-
aws ecs update-service \
81-
--cluster $CDK_BASIC_CLUSTER \
82-
--service $SERVICE_NAME \
83-
--service-connect-configuration 'enabled=false' \
84-
--no-cli-pager --query 'service.serviceArn' --output text
85-
86-
done
8775

8876
npm install
89-
9077
npx cdk bootstrap
78+
79+
npx cdk diff tenant-template-stack-basic > ./diff_output.txt 2>&1
80+
if grep -q "There were no differences" ./diff_output.txt; then
81+
echo "No changes detected in tenant-template-stack-basic."
82+
else
83+
echo "Changes detected in tenant-template-stack-basic."
84+
85+
SERVICES=$(aws ecs list-services --cluster $CDK_BASIC_CLUSTER --query 'serviceArns[*]' --output text || true)
86+
for SERVICE in $SERVICES; do
87+
SERVICE_NAME=$(echo $SERVICE | rev | cut -d '/' -f 1 | rev)
88+
89+
echo -n "==== Service Connect Disable: "
90+
aws ecs update-service \
91+
--cluster $CDK_BASIC_CLUSTER \
92+
--service $SERVICE_NAME \
93+
--service-connect-configuration 'enabled=false' \
94+
--no-cli-pager --query 'service.serviceArn' --output text
95+
done
96+
fi
97+
rm diff_output.txt
98+
9199
npx cdk deploy --all --require-approval=never
92100

93-
# Get SaaS application url
101+
102+
## Get SaaS application url
94103
ADMIN_SITE_URL=$(aws cloudformation describe-stacks --stack-name controlplane-stack --query "Stacks[0].Outputs[?OutputKey=='adminSiteUrl'].OutputValue" --output text)
95104
APP_SITE_URL=$(aws cloudformation describe-stacks --stack-name core-appplane-stack --query "Stacks[0].Outputs[?OutputKey=='appSiteUrl'].OutputValue" --output text)
96105
echo "Admin site url: $ADMIN_SITE_URL"

0 commit comments

Comments
 (0)