3

伙计们,我正在尝试通过 ruby​​ aws-sdk 和 iam 角色提取 EC2 标签。以下代码在下面产生错误。我究竟做错了什么?

require 'rubygems'
require 'aws-sdk'
require 'fileutils'

ec2 = AWS::EC2.new()

instance_id = `wget -q -O - http://169.254.169.254/latest/meta-data/instance-id`
outdir = '/opt/facts/tags/'

unless File.directory?(outdir)
  FileUtils.mkdir_p(outdir)
end

ec2= AWS::EC2.new()
instance = ec2.instances[instance_id]
tags = instance.tags

tags.each do |num|
  File.open(outdir+num[0], "w") do |f|
    f.write(num[1])
  end
end

以下输出:

/usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/http/connection_pool.rb:127:in `session_for': undefined method `continue_timeout=' for #<Net::HTTP ec2.us-east-1.amazonaws.com:443 open=false> (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/http/net_http_handler.rb:52:in `handle'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/client.rb:236:in `make_sync_request'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/client.rb:262:in `retry_server_errors'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/client.rb:229:in `make_sync_request'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/client.rb:489:in `client_request'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/client.rb:371:in `log_client_request'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/client.rb:457:in `client_request'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/client.rb:353:in `return_or_raise'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/core/client.rb:456:in `client_request'
from (eval):3:in `describe_tags'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/ec2/filtered_collection.rb:44:in `send'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/ec2/filtered_collection.rb:44:in `filtered_request'
from /usr/lib/ruby/gems/1.8/gems/aws-sdk-1.9.0/lib/aws/ec2/resource_tag_collection.rb:156:in `each'
from ./puppetclient.rb:22
4

2 回答 2

3

这似乎是今天已经报告的一个错误:未定义的方法 `continue_timeout=',您可以尝试指向 git 存储库的主分支,因为它已经有一个补丁。

编辑:

您已经可以指向最新版本,rubygems因为他们已经在以下位置部署了修复程序version 1.9.1https ://rubygems.org/gems/aws-sdk

于 2013-04-18T18:40:31.383 回答
1

今天在 AWS-SDK-ruby https://github.com/aws/aws-sdk-ruby/issues/232中宣布了一个错误

您可以通过更新 gemfile 来修复它

gem 'aws-sdk', "1.9.1"

然后运行“捆绑”

于 2013-04-18T19:04:50.467 回答