0.0.8 • Published 10 years ago

aws-elb-utils v0.0.8

Weekly downloads
43
License
MIT
Repository
-
Last release
10 years ago

aws-elb-util

A few utilities to let an AWS EC2 instance figure out whether it is the only instance (or 'first' instance) on a Load Balancer. The main purpose if to make it easy to ensure that single instances of a worker process can be run in an installation as servers get added and taken down.

npm install aws-elb-util


var awsUtil = require('aws-elb-utils');

Configure through config file, which must include owner_id. AWS accessKeyId and secretAccessKey can be in config file or in environment variables AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY.

awsUtil.configure(configFilename);

Determining whether you are running on EC2

awsUtil.onEC2 (function (err, onEC2) {
  ;
});
 

Getting the instance id

awsUtil.getInstanceId (function (err, instanceId) {
  ;
});

Get information about load balancers

awsUtil.getLoadBalancers (configObject, function(err, loadBalancers)) {
  ;
});

See if you are the 'primary' instance

awsUtil.amIFirst(function (err, primary, loadBalancer) {
   // primary is a boolean
   // load balancer is the name of the load balancer 
   //   or 
   // -1 (Running on EC2 but not under a load balancer)
   //   or
   // -2 (Not running on EC2)
 });

Handle changing state

awsUtil.handlePromotionDemotion( 
  function onPromotionToPrimary() {},
  function onDemotionFromPrimary() {}
);
0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago