Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions master_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ ebstemplate=""
#AWS_S3_BUCKET=""
#AWS_S3_SOURCE_SYNC_PATH=""
CFCACHE="false"
# AWS_CLOUD_FRONT_ID=""

# Variables for Lambda
#AWS_LAMBDA_DEPLOY_TYPE=""
Expand Down Expand Up @@ -696,6 +697,42 @@ deploy_s3bucket() {
done;
}

check_invalidation_status() {
INVALIDATE_ID=$1
counter=0
echo "invalidating cache with ID $INVALIDATE_ID"
sleep 60
invalidatestatus=`aws cloudfront get-invalidation --distribution-id $AWS_CLOUD_FRONT_ID --id $INVALIDATE_ID | $JQ '.Invalidation.Status'`

while [[ $invalidatestatus != *"Completed"* ]]
do
echo $invalidatestatus
echo "Waiting for 15 sec and try to check the invalidation status..."
sleep 15
invalidatestatus=`aws cloudfront get-invalidation --distribution-id $AWS_CLOUD_FRONT_ID --id $INVALIDATE_ID | $JQ '.Invalidation.Status'`
counter=`expr $counter + 1`
if [[ $counter -gt $COUNTER_LIMIT ]] ; then
echo "Invalidation does not complete with in 180 seconds. Please check the GUI mode."
exit 1
fi
done
echo "Invalidation completed"
}

invalidate_cf_cache()
{
if [ "$CFCACHE" = "true" ]; then
if [ -z $AWS_CLOUD_FRONT_ID ]; then
echo "Based on header applicaiton has invalidated"
echo "Skipped which is based on AWS cloudfront ID.Kindly raise request to configure cloud front ID in deployment configuration"
else
#aws cloudfront create-invalidation --distribution-id $AWS_CLOUD_FRONT_ID --paths '/*'
INVALIDATE_ID=`aws cloudfront create-invalidation --distribution-id $AWS_CLOUD_FRONT_ID --paths '/*' | $JQ '.Invalidation.Id'`
check_invalidation_status "$INVALIDATE_ID"
fi
fi
}

download_envfile()
{
Buffer_seclist=$(echo $SEC_LIST | sed 's/,/ /g' )
Expand Down Expand Up @@ -1127,6 +1164,7 @@ main()
if [ "$DEPLOYMENT_TYPE" == "CFRONT" ]
then
deploy_s3bucket
invalidate_cf_cache
fi

if [ "$DEPLOYMENT_TYPE" == "LAMBDA" ]
Expand Down