Amazon Simple Storage Service
Developer Guide (API Version 2006-03-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Making Requests Using AWS Account or IAM User Credentials - AWS SDK for Ruby

The following tasks guide you through using the AWS SDK for Ruby to send authenticated requests using your AWS Account credentials or IAM user credentials.

Making Requests Using Your AWS Account or IAM user Credentials

1

Create an instance of the AWS::S3 class by providing your AWS Account or IAM user credentials (Access Key ID, Secret Access Key).

2

Make a request to Amazon S3 by enumerating objects in a bucket using the buckets method of AWS::S3. The client generates the necessary signature value from your credentials and includes it in the request it sends to Amazon S3.


The following Ruby code sample demonstrates the preceding tasks.

# Get an instance of the S3 interface using the specified credentials configuration.
s3 = AWS::S3.new(  
  :access_key_id => my_access_key_id,
  :secret_access_key => my_secret_key)

# Get a list of all object keys in a bucket.
bucket = s3.buckets[bucket_name].objects.collect(&:key)
puts bucket

[Note]Note

You can create the AWS:S3 client without providing your security credentials. Requests sent using this client are anonymous requests, without a signature. Amazon S3 returns an error if you send anonymous requests for a resource that is not publicly available.

For working examples, see Working with Amazon S3 Objects and Working with Amazon S3 Buckets. You can test these examples using your AWS Account or IAM user credentials.