Created
August 16, 2012 16:43
-
-
Save fredjean/3371568 to your computer and use it in GitHub Desktop.
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
require 'right_aws' | |
def instances_from_ec2(load_balancer = nil) | |
load_balancer ||= aws_load_balancer | |
payload = elb.describe_load_balancers(load_balancer) | |
instances = ec2.describe_instances payload.first[:instances] | |
instances.collect{|instance| instance[:dns_name] if (instance[:aws_state] == 'running')} | |
end | |
def elb | |
@elb ||= RightAws::ElbInterface.new(aws_access_key_id, aws_secret_access_key, :region => 'us-west-1') | |
end | |
def ec2 | |
@ec2 ||= RightAws::Ec2.new(aws_access_key_id, aws_secret_access_key, :region => 'us-west-1') | |
end |
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
role :web do | |
instances_from_ec2 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment