@@ -49,10 +49,18 @@ ATTEMPTS=45
4949SLEEPTIME=10
5050COUNTER=1
5151INSTANCE_IDS=" "
52- until [ ` wc -w <<< $INSTANCE_IDS ` -eq $DEIS_NUM_INSTANCES ]; do
53- if [ $COUNTER -gt $ATTEMPTS ]; then exit 1; fi # timeout after 7 1/2 minutes
54- if [ $COUNTER -ne 1 ]; then sleep $SLEEPTIME; fi
55- echo "Waiting for instances to be created..."
52+ until [ ` wc -w <<< $INSTANCE_IDS ` -eq $DEIS_NUM_INSTANCES -a " $STACK_STATUS " = " CREATE_COMPLETE" ]; do
53+ if [ $COUNTER -gt $ATTEMPTS ]; then echo " Timed out waiting for instances..." ; exit 1; fi # timeout after 7 1/2 minutes
54+ echo "Waiting for instances to be created... $STACK_STATUS"
55+ sleep $SLEEPTIME
56+ STACK_STATUS=$(aws --output text cloudformation describe-stacks --stack-name $STACK_NAME --query 'Stacks[].StackStatus')
57+ if [ $STACK_STATUS != "CREATE_IN_PROGRESS" -a $STACK_STATUS != "CREATE_COMPLETE" ] ; then
58+ echo "error creating stack: "
59+ aws --output text cloudformation describe-stack-events \
60+ --stack-name $STACK_NAME \
61+ --query 'StackEvents[?ResourceStatus== ` CREATE_FAILED` ].[LogicalResourceId,ResourceStatusReason]'
62+ exit 1
63+ fi
5664 INSTANCE_IDS=$(aws ec2 describe-instances \
5765 --filters Name=tag:aws:cloudformation:stack-name,Values=$STACK_NAME Name=instance-state-name,Values=running \
5866 --query ' Reservations[].Instances[].[ InstanceId ]' \
6472COUNTER=1
6573INSTANCE_STATUSES=""
6674until [ `wc -w <<< $INSTANCE_STATUSES` -eq $DEIS_NUM_INSTANCES ]; do
67- if [ $COUNTER -gt $ATTEMPTS ]; then exit 1; fi # timeout after 7 1/2 minutes
75+ if [ $COUNTER -gt $ATTEMPTS ]; then echo "Timed out waiting for instances..." ; exit 1; fi # timeout after 7 1/2 minutes
6876 if [ $COUNTER -ne 1 ]; then sleep $SLEEPTIME; fi
6977 echo "Waiting for instances to pass initial health checks..."
7078 INSTANCE_STATUSES=$(aws ec2 describe-instance-status \
0 commit comments