Created
May 11, 2018 00:35
-
-
Save endofcake/120472a9d8c3542dfe75d4f7f813a59c to your computer and use it in GitHub Desktop.
Check that ecs-agent is running and signal back to CloudFormation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
<...> | |
echo "Checking that agent is running" | |
until $(curl --output /dev/null --silent --head --fail http://localhost:51678/v1/metadata); do | |
printf '.' | |
sleep 1 | |
done | |
exit_code=$? | |
printf "\nDone\n" | |
# Can't signal back if the stack is in UPDATE_COMPLETE state, so ignore failures to do so. | |
# CFN will roll back if it expects the signal but doesn't get it anyway. | |
echo "Reporting $exit_code exit code to Cloudformation" | |
/opt/aws/bin/cfn-signal \ | |
--exit-code "$exit_code" \ | |
--stack "$CFN_STACK" \ | |
--resource ASG \ | |
--region "$REGION" || true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment