Create a gist now

Instantly share code, notes, and snippets.

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