Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Fog: A Powerful “Cloud Services” Gem

By Peter Cooper / June 12, 2010

fog is a Ruby gem by Wesley Beary to control a variety of cloud services through a unified API. It deals with both server cloud and storage based services and supports Amazon S3 and Rackspace Files; as well as servers and on Amazon EC2, Rackspace Servers, Terremark vCloud and Slicehost. Support is also available for Amazon ELB and SimpleDB.

The beauty of fog is how the same code interacts with different cloud services. It uses models, an idea familiar to anyone who has used an object mapper (like ActiveRecord), to abstract the common parts between cloud services. That leads to code that you can switch between cloud services easily. For handling features exclusive to a particular service, fog's Requests help you do just that. That means every cloud service has an internal API that you can use to utilize the uncommon feature of a particular service.

To give you a feel of its API, here is a command that creates an instance given the credentials are loaded up:

AWS.servers.create(:image_id => 'ami-5ee70037')

This one command actually sets up the whole instance and loads it up. The image architecture in Amazon EC2 helps, but having to skip the whole wizard with a simple command can't be matched. Moreover, this has a possibility of being used programmatically to load up instances and do crazy automated stuff. The README on the Github is helpful, and there is also a Getting Started guide to get you rolling with both S3 and EC2. fog is safe for production use and if you're searching for a powerful, extensible and an active gem, look no further!

This post was written by Rizwan Reza, a passionate, self-taught developer and designer who's been working with Rails since early 2005. Rizwan focuses on the start-to-finish product experience, all the way from branding to the application backend. You can find him on Twitter @rizwanreza.

Comments

  1. Wayne E. Seguin says:

    Wesley has done an awesome job on Fog, if you haven't tried it and you use cloud services, definitely do so.

  2. anon says:

    Anyone interested in this might also be interested in

    http://deltacloud.org/

  3. says:

    noted.
    It's a better way to do cloud services.

Other Posts to Enjoy

Twitter Mentions