Created
July 1, 2014 07:05
-
-
Save lox/b3433a09b2956e929742 to your computer and use it in GitHub Desktop.
A bash script to signal CloudFormation WaitConditions without cfn-bootstrap
This file contains 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 -e | |
## Signal CloudFormation WaitConditions without cfn-bootstrap | |
## See https://github.com/blake-education/aws-cfn-bootstrap/blob/master/bin/cfn-signal | |
if [ $# -eq 0 ] ; then | |
echo "usage: $0 <cfn url> <last exit code>" | |
exit 1 | |
fi | |
id=$(hostname -f)"_"$(date +"%s%N") | |
url="$1" | |
exitcode="${2:-0}" | |
# json params | |
status="SUCCESS" | |
reason="Configuration Complete" | |
id="llamas" | |
data="Application has completed configuration." | |
# check for failure | |
if [ "$exitcode" -ne 0 ] ; then | |
status="FAILURE" | |
data="Failed with exit code $exitcode" | |
fi | |
echo "notifying $url with $status (from $id)" | |
# http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-waitcondition.html | |
curl $url -X PUT -H 'Content-Type:' -d @- <<- JSON | |
{ | |
"Status" : "$status", | |
"Reason" : "$reason", | |
"UniqueId" : "$id", | |
"Data" : "$data" | |
} | |
JSON |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment