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 リポジトリのメイン ブランチを参照してみてください。

編集:

https://rubygems.org/gems/aws-sdkrubygemsに修正が既にデプロイされているため、最新バージョンを指定できversion 1.9.1ます 。

于 2013-04-18T18:40:31.383 に答える