Skip to content

Instantly share code, notes, and snippets.

@errorgem
Forked from joet3ch/fab_ec2.py
Created April 11, 2012 17:05
Show Gist options
  • Save errorgem/2360583 to your computer and use it in GitHub Desktop.
Save errorgem/2360583 to your computer and use it in GitHub Desktop.
Use fabric with dynamic auto scaling
def web_cluster():
env.user = 'ubuntu'
env.key_filename = ['mykey.pem']
env.conftype = 'prod'
env.project = 'sample'
ec2conn = ec2.connection.EC2Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
web_group = ec2conn.get_all_security_groups(groupnames=['web'])
for i in web_group[0].instances():
hostname = i.__dict__['public_dns_name']
if hostname is not '':
env.hosts.append(hostname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment