Created
May 21, 2014 14:45
-
-
Save davehewy/353d34ee3e4470a0359e to your computer and use it in GitHub Desktop.
Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fabric.api import * | |
import boto | |
from boto import regioninfo | |
from boto import ec2 | |
from boto.ec2.elb import ELBConnection | |
import app | |
# Some default environment settings | |
env.user = 'ec2-user' | |
env.aws_region = 'eu-west-1' | |
# Get the correct ELB region to use from the endpoint | |
elb_region = boto.regioninfo.RegionInfo( | |
name='eu-west-1', | |
endpoint='elasticloadbalancing.eu-west-1.amazonaws.com') | |
# Make a connection to that ELB | |
elb = boto.connect_elb(region=elb_region) | |
# Instantiate an empty list for instances | |
instanceList = [] | |
@task | |
def elb_list(load_balancer_name='public-elb', project='', environment='stge'): | |
loadBalancer = elb.get_all_load_balancers([load_balancer_name + '-' + project + '-' + environment])[0] | |
if loadBalancer: | |
instanceList.extend(loadBalancer.instances) | |
for instance in instanceList: | |
print instance.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment