Skip to content

bmizerany/swirl-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

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
  ...
})

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published