I spend a lot of time kicking off EC2 instances for testing, bug reproduction, general information gathering, etc. These instances don’t have any sort of long-term life. Every so often I simply want to kill them all off, and I want to do so using the command line.
~/terminate-all-instances-in-region with permissions of
$ cat terminate-all-instances-in-region
euca-describe-instances | grep INSTANCE | sed 's/INSTANCE[[:space:]]*\(i-[[:alnum:]]*\).*/\1/' | xargs euca-terminate-instances
ec2- if you are using the Amazon EC2 API Tools.
This assumes that your EC2 region is set via the
EC2_URL environment variable. See this post for more details.