The following code is intended to add a newly deployed EC2 instance in a VPC to a load balancer. (This is pretty obviously test/dummy code, but the general workflow is the same in a real system)
require 'yaml'
gem 'aws-sdk','1.6.0'
require 'aws-sdk'
AWS.config({
:access_key_id => KEY,
:secret_access_key => SECRET_KEY
})
ec2 = AWS::EC2.new
elb = AWS::ELB.new
i = ec2.instances["i-abcd1234"]
elb.load_balancers["lb-name"].instances.register(i)
When I run this code, I get this error:
AWS::ELB::Errors::ValidationError: ELB in VPC is not supported in this version of API. Please try 2011-11-15 or newer.
My aws-sdk gem is the most current version available through RubyGems, it was updated this week. Is this just not a feature available in the Ruby SDK for AWS? What can I do to add a VPC node to a Load Balancer with Ruby code, through this gem or otherwise?
Resolved: This error was the result of the ELB portion of the aws-sdk gem using an old version of the AWS API. A new gem version (1.6.1) was released on August 6, 2012 which causes ELB to use the 2012-06-01 version of the API, and now instances can be added to an ELB using code like in the question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With