node package manager


node-awsm =========

Here's how:

var aws = require("awsm")(require("./awsConfig")).chain();
// let's go ahead and provision a few ubuntu instances around the globe. 
aws.regions().all().createInstance({ type: "m3.medium", imageId: "ami-a73264ce" }).start().then(function (err, instances) {

How about migrating a pre-existing image? Easy:

aws.regions().all(function (err, regions) {
  aws.images().find({ "tags.type": "my-awesome-application" }).migrate(regions).then(function (err, images) {
    // should be roughly ~ 7 images that have been migrated to every 
    // AWS region.  

Awsm is also extendable. Want to add SSH? No problem:

var aws = require("awsm")(require("./awsConfig"));
var awsc = aws.chain();
  // find all servers in the staging environment 
  find({ "tags.env": "staging", "tags.type": "my-mega-awesome-application" }).
  // let's copy some local files to all mega awesome applications. 
  rsync("~/Developer/applications/my-mega-awesome-application", "/remote/app/directory").
  // let's start this sucker. 
  exec("node /remote/app/directory").
  // after the process closes - this will never happen since exec (above) won't close. Have 
  // you taken a look at node-awsm-cli?  
  then(function (err, instances) {
    // donezo. 

Want a command line interface? This is not the repository you're looking for. Checkout awsm-cli.

  • awsm-keypair-save - allows you to save keypairs locally immediately after creating them.
  • awsm-ssh - super nice utility that allows you to ssh, execute scripts, and rsync files on your EC2 instances.

Initializes the awsm library.

  • key - aws key
  • secret - aws secret
  • ec2 - the ec2 config
    • regions (array) - regions to use (["us-east-1", "us-west-1", ...])
  • log - log config
    • level - the log level to use - notice, verbose, warn, error

Resource collections share a common API, and are used for every object type which includes regions, instances, images, securityGroups, and keyPairs.

Finds many resources in the target collection.

// find all U.S. regions 
awsm.ec2.regions.find({ name: /^us/ }, onUsRegions);
// find all running instances in a given region 
region.instances.find({ state: "running" }, onAllRunningInstances);

Finds one resource against a target collection.

// find an image with the given name 
region.images.findOne({ name: "some-image-name" }, onImage);

Below are a list of available collections to search against

  • awsm.ec2.instances - all instances across all regions.
  • awsm.ec2.images - all images across all regions.
  • awsm.ec2.regions - all regions.
  • region.instances - instances specific to the region.
  • region.images - images specific to the region.

Awsm allows you to interface against multiple EC2 regions pretty easily - all you need to do is pass which regions you want to use in the main config.

var aws = awsm({
  key: "KEY",
  secret: "SECRET"
  ec2: {
    regions: ["us-east-1", "us-west-2"]

Note that the regions property is completely optional - awsm will automatically default to all EC2 regions if the property is omitted.

Here are a few examples of how you might interact with awsm regions:

// init awsm 
var awsm = awsm({ key: "key", secret: "secret" });
// get all regions 
// find all U.S. regions 
awsm.ec2.regions.find({ name: /^us/ }, onAllUSRegions);
// find ALL instances in ALL regions 
// find ALL RUNNING instances in ALL regions 
awsm.ec2.instances.find({ state: "running" }, onAllRunningInstances);

Allows you to tag specific instances, images, security groups, or key pairs.

Updates the tags on the specific resource

instance.tags.update({ type: "mongodb" }, function () {
  console.log(instance.get("tags")); // { type: mongodb } 

Creates a new instance in the target region.

  • imageId - (required) imageId to use
  • count - (default = 1) number of instances to create
  • flavor - (default = t1.micro) type of instance to use (t1.micro, m1.medium)
  • securityGroup - (optional) the security group object to use with the instance
  • keyPair - (optional) the key pair object to use with the instance
region.instances.create({ imageId: "ami-a73264ce" }, function (err, instance) {
  console.log(instance.get("state")); // running 
  console.log(instance.get("_id")); // instance id 

starts the instance

restarts the instance

stops the instance

creates an image out of the instance

returns all the volumes attached to the instance

returns all the securityGroups attached to the instance

returns the allocated address assigned to the specific instance

returns the image used to create the instance

returns the keypair assigned to the instance

instance tags collection

destroys the instance

creates a new image

creates a new instance from the image

migrates the image to another region

destroys the image

allocates a new address

associates an address with an instance

detaches from an instance

returns the instance associated with the address

address tags collection

releases the address

creates a new volume

attaches to an instance

detaches from an instance

returns all the instances this volume is attached to

creates a new snapshot of the volume

destroys the volume

creates a snapshot

creates a volume out of the snapshot

returns the snapshot associated with the given volume

destroys the snapshot

creates a new keypair

destroys the keypair

creates a security group

authorizes a port in the security group

revokes port

destroys the security group.

TODO - Checkout the examples at the top.