Posted On: Sep 25, 2014

The new Resource APIs for the Version 2 Preview of the AWS SDK for Ruby are now available on Ruby Gems. These APIs are designed to help developers write more intuitive and resource-oriented code for working with AWS services. AWS resources such as EC2 instances and S3 objects are exposed as Ruby objects, with attributes that are automatically loaded from the service when accessed for the first time, and methods that map to various actions available for the resource objects. Improved from similar concepts that exist in the Version 1 of the SDK, the new APIs introduce a number of improvements including easier control over underlying network calls, model-driven resource classes, and resource waiters. While the request-response APIs available in the aws-sdk-core gem allow explicit and granular control over the network calls your application makes to AWS, using the new resource APIs can help you simplify your code and reduce development time.

Here are some quick examples to demonstrate:

# Get reference to resource, retrieve metadata, and perform actions
s3 = 'us-west-2')
object = s3.bucket('my-bucket').object('my-object.txt')

# Iterate over resource collection and perform batch operations
bucket.objects.each { |obj| ... }

# Efficiently poll for state changes with resource waiters
instance = ec2.instance('i-1234567')
puts + 'has been stopped.'

Currently, Resource APIs are available for Amazon EC2, Amazon S3, AWS IAM, Amazon Glacier, Amazon SNS, and Amazon SQS. The team plans to add support for more services and expand the capabilities during the preview period. We encourage you to try out the new APIs and send us feedback via GitHub Issues.

Find more information on AWS Ruby Development Blog

Add the package to your project using Ruby Gems - "gem install aws-sdk --pre"
Download the gem file
Browse the code
Browse the API reference