Skip to content

Commit e4ebaf8

Browse files
author
Elliot
committed
adding script cutover.sh to allow manual cutover from blue to green environment
1 parent f2a33ca commit e4ebaf8

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ RUN pip3 install --no-cache --upgrade boto3
88

99
ADD src .
1010

11-
RUN chmod +x deploy.sh task-deploy.sh run-task.sh tail-task-logs.py
11+
RUN chmod +x deploy.sh task-deploy.sh run-task.sh cutover.sh tail-task-logs.py
1212

1313
ENTRYPOINT [ "/bin/bash", "-c" ]
1414

15-
CMD [ "/work/deploy.sh" ]
15+
CMD [ "/work/deploy.sh" ]

src/cutover.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash -e
2+
3+
ERROR=0
4+
if [[ -z "$AWS_DEFAULT_REGION" ]]; then echo "---> ERROR: Missing variable AWS_DEFAULT_REGION"; ERROR=1; fi
5+
if [[ -z "$APP_NAME" ]]; then echo "---> ERROR: Missing variable APP_NAME"; ERROR=1; fi
6+
if [[ -z "$CLUSTER_NAME" ]]; then echo "---> ERROR: Missing variable CLUSTER_NAME"; ERROR=1; fi
7+
if [[ -z "$CONTAINER_PORT" ]]; then echo "---> ERROR: Missing variable CONTAINER_PORT"; ERROR=1; fi
8+
if [[ -z "$IMAGE_NAME" ]]; then echo "---> ERROR: Missing variable IMAGE_NAME"; ERROR=1; fi
9+
if [[ "$ERROR" == "1" ]]; then exit 1; fi
10+
11+
# Fetch deployment ID pending cutover to the green(new) enviroment
12+
DEPLOYMENT_ID=$(aws deploy list-deployments --application-name=$CLUSTER_NAME-$APP_NAME --deployment-group=$CLUSTER_NAME-$APP_NAME --max-items=1 --query="deployments[0]" --output=text | head -n 1)
13+
14+
DEPLOYMENT_PID=$!
15+
16+
#echo "---> For More Deployment info: https://$AWS_DEFAULT_REGION.console.aws.amazon.com/codesuite/codedeploy/deployments/$DEPLOYMENT_ID"
17+
18+
#echo "---> Waiting for Deployment ..."
19+
20+
aws deploy continue-deployment --deployment-id $DEPLOYMENT_ID --deployment-wait-type "READY_WAIT"
21+
22+
wait $DEPLOYMENT_PID
23+
RET=$?
24+
25+
if [ $RET -eq 0 ]; then
26+
echo "---> Deployment completed!"
27+
else
28+
echo "---> ERROR: Deployment FAILED!"
29+
fi
30+
31+
exit $RET

0 commit comments

Comments
 (0)