Script to list AWS EC2 Instances
#!/bin/bash
tmpFile="/tmp/ec2.info"
ec2Info=`ec2-describe-instances > $tmpFile`
instances=`cat $tmpFile | grep TAG | awk {'print $3'}`
numOfInstances=`cat $tmpFile | grep INSTANCE | wc -l`
you=`whoami`
echo "Dear $you, I wanted to describe for you the current number of instances you have: $numOfInstances"
echo "The instances you have, by hostname, are as follows ..."
for instance in $instances
do
hostname=`cat $tmpFile | grep INSTANCE | grep $instance | awk {' print $4 '}`
echo "$hostname"
done
Written by Darren Holdaway
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ec2
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#