Reputation: 23492
I am running fairly simple program to list S3 buckets. There are two approaches. However, both the approaches give me same error.
Approach 1: Create a s3 client and then access the client methods(list_buckets
).
Code:
#!/usr/bin/ruby
require 'aws-sdk'
require 'awesome_print'
AWS.config( :access_key_id => 'My Access Key',
:secret_access_key => 'My Secret Key',
:region => 'us-west-2')
s3 = AWS.s3
puts s3.client.list_buckets()
Output:
/var/lib/gems/1.9.1/gems/aws-sdk-1.14.1/lib/aws/s3/client.rb:459:in `block (2 levels) in <class:Client>': uninitialized constant AWS::Core::XML::ListBuckets (NameError)
Approach 2: Create a Bucket Object and then Enumerate it.
Code:
#!/usr/bin/ruby
require 'aws-sdk'
require 'awesome_print'
AWS.config( :access_key_id => 'My Access Key',
:secret_access_key => 'My Secret Key',
:region => 'us-west-2')
s3obj = AWS::S3.new
s3obj.buckets.each do |bucket|
puts bucket
end
OutPut:
/var/lib/gems/1.9.1/gems/aws-sdk-1.14.1/lib/aws/s3/client.rb:459:in `block (2 levels) in <class:Client>': uninitialized constant AWS::Core::XML::ListBuckets (NameError)
What am I doing wrong here? AFAIK, My code follows what is mentioned in each approach. This is the most basic code to list buckets and I am failing at it.
Upvotes: 1
Views: 2345
Reputation: 23492
After reading the error more carefully, I found aws-sdk-1.14.1
. So then I checked on AWS and realized that they have a newer version of Ruby SDK released. It was 1.29.1
.
ruby 1.9.2
from source
nokogiri
which in turn need ruby 1.9.2 or later.AWS-SDK 1.29.1
And Now both above my code are working just fine.
So, it was probably older version of SDK that was causing the error.
Upvotes: 1