Project

swirl

0.01
No commit activity in last 3 years
No release in over 3 years
A version agnostic EC2 ruby driver
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0.1.2

Runtime

>= 0.1.4
>= 0.3.2
 Project Readme

Swirl

Swirl is an EC2 version agnostic client for EC2 written in Ruby. It gets out of your way.

The secret is it's simple input extraction and output compacting. Your input parameters and expanded and EC2's (terrible) xml output is compacted.

Some simple examples:

# Input
{ "InstanceId" => ["i-123k2h1", "i-0234d3"] }

is expanded to:

{ "InstanceId.0" => "i-123k2h1", "InstanceId.1" => "i-0234d3" }

in the case that .n isn't at the end of the key:

{ "Foo.#.Bar" => ["a", "b"] }

is expanded to:

{ "Foo.0.Bar" => "a", "Foo.1.Bar" => "b" }

and

# Output
{
  "reservationSet" => {
    "item" => {
      "instancesSet" => { "item" => [ ... ] }
    }
  }
}

and it's variations are now compacted to:

{ "reservationSet" => { "instancesSet" => [ { ... }, { ... } ] } }

Some things worth noting is that compact ignores Symbols. This allows you to pass the params into call and use them later without affecting the API call (i.e. chain of responsibility); a nifty trick we use in (Rack)[http://github.com/rack/rack]

Use

require 'swirl/aws'

ec2 = Swirl::AWS.new(:ec2)

# Describe all instances
ec2.call "DescribeInstances"

# Describe specific instances
ec2.call "DescribeInstances", "InstanceId" => ["i-38hdk2f", "i-93nndch"]

# Talk to a different region
ec2_asia = Swirl::AWS.new(:ec2, :region => 'ap-southeast-1')

Shell

$ swirl -h
Usage: swirl [options]
    -a ACCOUT                        Account name (default is default)
    -c FILE                          Swirl file (default is ~/.swirl)
    -s service                       The AWS service to use (default is ec2)
    -r region                        The AWS region to use (default is up to AWS)
    -h, --help


$ swirl
>> c
<Swirl::EC2 ... >
>> c.call "DescribeInstances"
...

The shell respects your ~/.swirl file for configuration