Skip to content

Instantly share code, notes, and snippets.

@jared-christensen
Created October 29, 2021 04:10
Show Gist options
  • Save jared-christensen/a5ed20c6fb27539bce5fb351e7cccbd5 to your computer and use it in GitHub Desktop.
Save jared-christensen/a5ed20c6fb27539bce5fb351e7cccbd5 to your computer and use it in GitHub Desktop.
Wait for AWS AppRunner deploy to succeed for CodeBuild step in CodePipeline
#!/bin/bash
ARN=$1
echo "- ARN: $ARN"
OPERATION=""
STATUS=""
while [ "$STATUS" != "SUCCEEDED" ]
do
OPERATION=$(aws apprunner list-operations --service-arn "$ARN" --output text | grep -m1 "")
STATUS=$(echo $OPERATION | grep -oE "PENDING|IN_PROGRESS|FAILED|SUCCEEDED|ROLLBACK_IN_PROGRESS|ROLLBACK_FAILED|ROLLBACK_SUCCEEDED")
echo "- STATUS: $STATUS"
if [ "$STATUS" != "PENDING" ] && [ "$STATUS" != "IN_PROGRESS" ] && [ "$STATUS" != "SUCCEEDED" ]
then
echo "- OPERATION: $OPERATION"
exit 1
fi
sleep 1
done
@stokedout
Copy link

Doesn't seem to work anymore since the next token is at the top of the text, I adapted it to this:

#!/bin/bash

ARN=$1
echo "- ARN: $ARN"

STATUS=""

while [ "$STATUS" != "SUCCEEDED" ]
do
  STATUS=$(aws apprunner list-operations --region eu-central-1 --service-arn "$ARN" --max-results 1 --output json | grep -m 1 '"Status"' | sed 's/.*"Status": "\(.*\)",/\1/';)
  echo "- STATUS: $STATUS"
  if [ "$STATUS" != "PENDING" ] && [ "$STATUS" != "IN_PROGRESS" ] && [ "$STATUS" != "SUCCEEDED" ]
  then
    echo "Deployment failed"
    exit 1
  fi
  sleep 1
done

echo "Deployment succeeded"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment