一个VPC节点添加到ELB编程 [英] Add a VPC node to ELB programmatically

查看:165
本文介绍了一个VPC节点添加到ELB编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面code为旨在以VPC添加一个新部署的EC2实例给负载平衡器。 (这是pretty的明显测试/假人code,而一般工作流程是一样的在实际系统中)

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)

当我运行此code,我得到这个错误:

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.

我的AWS-SDK的宝石可以通过RubyGems的最新版本,它于本周更新。这只是不是在Ruby SDK的AWS提供一个功能?我能做些什么,以一个VPC节点添加到负载平衡器使用Ruby code,通过这种宝石或以其他方式?

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?

推荐答案

解决:此错误是AWS-SDK宝石ELB部分使用的是旧版本的AWS API的结果。一个新的宝石版本(1.6.1)发布于2012年8月6日这会导致ELB使用2012-06-01版本的API,而现在情况下可以用code像在问题被添加到ELB

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.

这篇关于一个VPC节点添加到ELB编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆