Skip to content
No description or website provided.
JavaScript
Latest commit f820b45 May 20, 2010 @bmizerany updated README
Failed to load latest commit information.
lib ... May 20, 2010
.gitignore ... May 20, 2010
README.md updated README May 20, 2010

README.md

Swirl for Node (a port of my Ruby version)

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

The secret is it's simple input extraction are 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 varations are now compacted to:

{ "reservationSet" : { "instancesSet" : [ { ... }, { ... } ] } }

Use

var swirl = require("swirl") // add to your loadpath if needed
ec2 = swirl.createEC2Client(my_key, my_secret)

# Describe all instances
ec2.call("DescribeInstances", {}, function(result) {
  var instances = result.reservationSet[0].instancesSet
  ...
})

# Describe specific instances
var query = { InstanceId: ["i-38hdk2f", "i-93nndch"] }
ec2.call("DescribeInstances", query, function(result) {
  var instances = result.reservationSet[0].instancesSet
  ...
})
Something went wrong with that request. Please try again.