Skip to content

Commit

Permalink
Merge pull request #6 from elliot-dnx/master
Browse files Browse the repository at this point in the history
adding script cutover.sh to allow manual cutover from blue to green e…
  • Loading branch information
adenot authored Mar 28, 2020
2 parents f2a33ca + e4ebaf8 commit e1377da
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ RUN pip3 install --no-cache --upgrade boto3

ADD src .

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

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

CMD [ "/work/deploy.sh" ]
CMD [ "/work/deploy.sh" ]
31 changes: 31 additions & 0 deletions src/cutover.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash -e

ERROR=0
if [[ -z "$AWS_DEFAULT_REGION" ]]; then echo "---> ERROR: Missing variable AWS_DEFAULT_REGION"; ERROR=1; fi
if [[ -z "$APP_NAME" ]]; then echo "---> ERROR: Missing variable APP_NAME"; ERROR=1; fi
if [[ -z "$CLUSTER_NAME" ]]; then echo "---> ERROR: Missing variable CLUSTER_NAME"; ERROR=1; fi
if [[ -z "$CONTAINER_PORT" ]]; then echo "---> ERROR: Missing variable CONTAINER_PORT"; ERROR=1; fi
if [[ -z "$IMAGE_NAME" ]]; then echo "---> ERROR: Missing variable IMAGE_NAME"; ERROR=1; fi
if [[ "$ERROR" == "1" ]]; then exit 1; fi

# Fetch deployment ID pending cutover to the green(new) enviroment
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)

DEPLOYMENT_PID=$!

#echo "---> For More Deployment info: https://$AWS_DEFAULT_REGION.console.aws.amazon.com/codesuite/codedeploy/deployments/$DEPLOYMENT_ID"

#echo "---> Waiting for Deployment ..."

aws deploy continue-deployment --deployment-id $DEPLOYMENT_ID --deployment-wait-type "READY_WAIT"

wait $DEPLOYMENT_PID
RET=$?

if [ $RET -eq 0 ]; then
echo "---> Deployment completed!"
else
echo "---> ERROR: Deployment FAILED!"
fi

exit $RET

0 comments on commit e1377da

Please sign in to comment.