Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JavaScript
Branch: master
Pull request Compare This branch is 19 commits behind camerondgray:master.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
README
Readme.md
index.js
makefile
package.json

Readme.md

aws-ec2

A small library for launching, describing, and terminating Amazon Web Services (AWS) EC2 instances

Installation

$ npm install aws-ec2

Usage

var aws = require('aws-ec2')(myAccessKey, mySecretAccessKey);

var instanceId;
var options = {
                'numToLaunch':1,
                'ami':'myAMI',
                'awsZone':'us-east-1a',
                'instanceType':'t1-micro',
                'securityGroups':["Production", "Web"]
            };
aws.launchOnDemandInstances(options, function (err, response) {
        instanceId = response.item.instanceId;
    });

Methods

launchOnDemandInstances(params, callback)

Launch one or more on demand instances. ami, awsZone, and instanceType are required. The other options can be found here

Receive a call back with callback(error,response) where the response is a RunningInstanceItemType

launchSpotInstances(params, callback)

Launch one ore more spot instances. Spot instances are reserved based on a maximum price bid for each instance. See AWS Spot Instances for more info on this cheaper alternative. ami, awsZone, and instanceType are required.

Recieve a call back with callback(error,response).

getInstanceDescriptionFromPrivateIp(privateIp, callback)

getInstanceDescriptionFromId(instanceId, callback)

describeSpotInstanceRequest(requestId, callback)

terminateEc2Instance(instanceId, callback)

cancelSpotRequest(requestId, callback)

Running tests

WARNING the integration tests will launch and terminate actual instances on EC2 which will cost you $$$!!

Install dev deps:

$ npm install -d

Edit /test/testConfig.json to include your actual awsKey and awsSecretKey and the options you want to use for testing

  {
      'accessKey':'yourAccessKey',
      'secretAccessKey':'yourSecretAccessKey',
      'awsZone':'us-east-1a',
      'instanceType':'t1.micro',
      'securityGroups':["YourSecurityGroup1", "YourSecurityGroup2"],
      'ami':'ami-yourAmi',
      'spotPrice':0.001
  }

Run the unit tests:

$ make test

Run the integration tests: Again, will launch and terminate actual instances

$ make test-integration

License

MIT

Something went wrong with that request. Please try again.