Created
October 7, 2010 13:49
-
-
Save craigbalding/615128 to your computer and use it in GitHub Desktop.
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 | |
# Kill all my running EC2 instances at Amazon AWS - all regions | |
. ~/.ec2/env | |
cat <<EOF | while read EC2_URL | |
https://eu-west-1.ec2.amazonaws.com | |
https://ec2.us-east-1.amazonaws.com | |
https://ec2.us-west-1.amazonaws.com | |
https://ec2.ap-southeast-1.amazonaws.com | |
EOF | |
do | |
ec2din --url $EC2_URL | gawk '/INSTANCE/ && /running/ { system("ec2-terminate-instances " $2) }' | |
done | |
# after a sleep, we list any leftover running instances in case terminate failed | |
sleep 30 | |
sh ~/awsls.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A quick and nasty script to terminate all running EC2 instances. I run this nightly from cron on a non-AWS server to ensure I haven't left any EC2 instances running. Obviously if you run production servers at EC2, either don't run this script or modify it to be more selective (e.g. using ec2 tags).