flexera-public / right_aws

RightScale Amazon Web Services Ruby Gems
MIT License
451 stars 175 forks source link

ELB new - issue passing in :region as aws param #95

Closed danmiley closed 12 years ago

danmiley commented 12 years ago

When passing in a region in the constructor args (anything other than us-east) the server name doesnt resolve correctly, instead we see a double reference of the prefix. e.g. Opening new HTTPS connection to us-east-1.us-east-1.ec2.amazonaws.com:443
Note duplication of us-east-1 subdomain.

any help would be much appreciated! or advise as to how to effectively reference a specific, non-default region when attempting to access a given ELB. The examples all seem to be oriented towards the default region us-east, since a region param is never set. The region param approach as below works fine for ELB rightscale instances. thanks!

details:

I am using current right_aws gem within a capistrano script context.

given this ruby code:

       set :aws_params, :region => 'us-west-1' 

       print 'params =' + fetch(:aws_params).to_s

     @elb_api ||= RightAws::ElbInterface.new(fetch(:aws_access_key_id), fetch(:aws_secret_access_key), fetch(:aws_params, {})

    print @elb_api.describe_load_balancers.to_s 

I get the following. , [2011-11-03T12:23:24.744988 #5478] INFO -- : New RightAws::Ec2 using shared connections mode
params = {:region=>"us-east-1", :server=>"us-east-1.ec2.amazonaws.com", :port=>443, :service=>"/", :protocol=>"https", :connection_options=>{}, :connections=>:shared, :max_connections=>10, :connection_lifetime=>1200, :api_version=>"201\ 0-08-31"}I, [2011-11-03T12:23:24.745271 #5478] INFO -- : New RightAws::ElbInterface using shared connections mode
I, [2011-11-03T12:23:24.746190 #5478] INFO -- : Opening new HTTPS connection to us-east-1.us-east-1.ec2.amazonaws.com:443

kagminjeong commented 12 years ago

Do not include "us-east-1" in :server, and in fact try not to specify the server at all if you are specifying region.

a=RightAws::ElbInterface.new(nil, nil, :region => 'us-west-1'); a.describe_load_balancers

I, [2011-11-08T18:28:56.983272 #30101]  INFO -- : New RightAws::ElbInterface using shared connections mode
I, [2011-11-08T18:28:56.983558 #30101]  INFO -- : Opening new HTTPS connection to us-west-1.elasticloadbalancing.amazonaws.com:443
a=RightAws::ElbInterface.new(nil, nil, :region => 'us-west-1',:server=>"ec2.amazonaws.com"); a.describe_load_balancers

I, [2011-11-08T18:30:54.575487 #30101]  INFO -- : New RightAws::ElbInterface using shared connections mode
I, [2011-11-08T18:30:54.575790 #30101]  INFO -- : Opening new HTTPS connection to us-west-1.ec2.amazonaws.com:443
W, [2011-11-08T18:30:54.924517 #30101]  WARN -- : ##### RightAws::ElbInterface returned an error: 400 Bad Request
RightAws::AwsError: NoSuchVersion: The requested version (2010-07-01) of service AmazonEC2 does not exist
konstantin-dzreev commented 12 years ago

Rich Meyers is right. The correct ways are:

elb = RightAws::ElbInterface.new(nil,nil, :server => 'us-west-1.elasticloadbalancing.amazonaws.com')

elb = RightAws::ElbInterface.new(nil,nil, :region => 'us-west-1', :server => 'elasticloadbalancing.amazonaws.com')

elb = RightAws::ElbInterface.new(nil,nil, :region => 'us-west-1')

danmiley commented 12 years ago

Thanks, guys, for the clarification. Works like a charm here.