Skip to content

Instantly share code, notes, and snippets.

@euank
Created February 14, 2017 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save euank/e3a8f59d70933cfec124f1f8477bfc20 to your computer and use it in GitHub Desktop.
Save euank/e3a8f59d70933cfec124f1f8477bfc20 to your computer and use it in GitHub Desktop.
#!/bin/bash
while true; do
instance_id=$(aws ec2 run-instances --key-name euank --instance-type m1.small --region=us-east-1 --image-id ami-8b7b759c | jq '.Instances[].InstanceId' -r)
sleep 20
while true; do
console=$(aws ec2 --region=us-east-1 get-console-output --instance-id $instance_id | jq '.Output' -r)
if [[ "$console" == "null" ]]; then
sleep 30
continue
fi
if grep "Reached target Multi-User System." <(echo $console); then
# Success!
echo "Success for $instance_id"
aws ec2 terminate-instances --region=us-east-1 --instance-ids $instance_id
break
fi
if grep "page_fault" <(echo $console); then
echo "Failure! for $instance_id"
echo $console
exit 1
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment