diff --git a/local-exec-scripts/create-codedeploy-deployment.sh b/local-exec-scripts/create-codedeploy-deployment.sh index 844fa63..bf4a4ad 100755 --- a/local-exec-scripts/create-codedeploy-deployment.sh +++ b/local-exec-scripts/create-codedeploy-deployment.sh @@ -60,6 +60,24 @@ DEPLOYMENT_REVISION=$( }' ) +echo "==> Checking current Deployments for '$APPLICATION_NAME' ..." +CURRENT_DEPLOYMENT="deployment_check" +while [ "$CURRENT_DEPLOYMENT" != "None" ] +do + CURRENT_DEPLOYMENT=$(aws deploy list-deployments \ + --application-name "$APPLICATION_NAME" \ + --deployment-group-name "$GROUP_NAME" \ + --include-only-statuses Created InProgress Queued \ + --output text \ + | head -n1 + ) + if [ "$CURRENT_DEPLOYMENT" != "None" ] + then + echo "There is a current deployment In Progress or Queued ($CURRENT_DEPLOYMENT). Waiting before creating a new one ..." + sleep 10 + fi +done + echo "==> Creating Deployment for '$APPLICATION_NAME' ..." DEPLOYMENT_ID=$( aws deploy create-deployment \ @@ -73,7 +91,7 @@ DEPLOYMENT_ID=$( echo "==> Checking deployment '$DEPLOYMENT_ID' ..." DEPLOYMENT_STATUS=$( aws deploy get-deployment \ - --deployment-id $DEPLOYMENT_ID \ + --deployment-id "$DEPLOYMENT_ID" \ --output text \ --query '[deploymentInfo.status]' ) @@ -89,7 +107,7 @@ do echo "==> Deployment status: $DEPLOYMENT_STATUS..." DEPLOYMENT_STATUS=$( aws deploy get-deployment \ - --deployment-id $DEPLOYMENT_ID \ + --deployment-id "$DEPLOYMENT_ID" \ --output text \ --query '[deploymentInfo.status]' )