Skip to content

Instantly share code, notes, and snippets.

@yuvalo
yuvalo / awsalert.py
Created November 20, 2012 14:33
Sets off a notification when you forget too many EC2 instances running.
import boto
import commands
# running instances threshold
limit = 4
conn = boto.connect_ec2('KEY','SECRET_KEY')
instances = conn.get_all_instance_status()
if (len(instances) > limit):
commands.getstatusoutput('terminal-notifier -message "Too many running instances: '+str(len(instances))+'" -title "Ec2 Alert"')