Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Node package for iterating ec2 instances and doing things.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

ec2-each

ec2-each is a node package for iterating EC2 instances and doing things.

Build Status

Installation

$ npm install ec2-each

Example

var logReservationIds = function(callback) {

  var config = {
    accessKeyId: "AAAABBBBCCCCDDDDEEEE",
    secretAccessKey: "aaaa2222bbbb3333cccc4444dddd5555eeeefff",
    awsAccountId: 123456789012,
    region: "eu-west-1"
  };

  var logReservationId = function(item, state, callback) {
    console.log(item.reservationId);
    callback(null);
  };

  var ec2 = new each.EC2(config);
  ec2.running(function(err, instances) {
    ec2.each(instances, logReservationId, null, callback);
  });

};

all(filters, callback)

Returns a set of all EC2 instances (irrespective of status) that can be passed into each. The supplied awssum filters will be applied.

running(action, callback)

Returns a set of all running EC2 instances that can be passed into each.

any(instances)

Returns true if instances is not empty

each(instances, action, state, callback)

Calls the action function once per EC2 instance passed in. The instances must be in the format as returned by all, running or an awssum DescribeInstances call.

The action could, for example, make an ssh call to the EC2 instance.

The state is passed to every action.

The callback is passed an error if any of the actions fail and the callback data contains an array of action results.

All actions are called in parallel.

Contributors

Pair programmed by Roy Lines and James Bloomer.

Something went wrong with that request. Please try again.