Skip to content

Commit

Permalink
added elb support
Browse files Browse the repository at this point in the history
  • Loading branch information
bkw committed Jun 15, 2011
1 parent 3a307ce commit edc8c61
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/elb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var aws = require("aws-lib");

elb = aws.createELBClient(yourAccessKeyId, yourSecretAccessKey);

elb.call("DescribeLoadBalancers", {}, function(result) {
console.log(JSON.stringify(result, null, 2));
})
2 changes: 2 additions & 0 deletions lib/aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var simpledb = require("./simpledb");
var sqs = require("./sqs");
var sns = require("./sns");
var ses = require("./ses");
var elb = require("./elb");

// Returns the hmac digest using the SHA256 algorithm.
function hmacSha256(key, toSign) {
Expand Down Expand Up @@ -112,3 +113,4 @@ exports.createSimpleDBClient = simpledb.init(genericAWSClient);
exports.createSQSClient = sqs.init(genericAWSClient);
exports.createSNSClient = sns.init(genericAWSClient);
exports.createSESClient = ses.init(genericAWSClient);
exports.createELBClient = elb.init(genericAWSClient);
33 changes: 33 additions & 0 deletions lib/elb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

exports.init = function(genericAWSClient) {
// Creates an ELB API client
var createELBClient = function (accessKeyId, secretAccessKey, options) {
options = options || {};

var client = elbClient({
host: options.host || "elasticloadbalancing.amazonaws.com",
path: options.path || "/",
accessKeyId: accessKeyId,
secretAccessKey: secretAccessKey,
secure: options.secure,
version: options.version
});
return client;
}
// Amazon ELB API handler which is wrapped around the genericAWSClient
var elbClient = function(obj) {
var aws = genericAWSClient({
host: obj.host, path: obj.path, accessKeyId: obj.accessKeyId,
secretAccessKey: obj.secretAccessKey, secure: obj.secure
});
obj.call = function(action, query, callback) {
query["Action"] = action
query["Version"] = obj.version || '2010-07-01'
query["SignatureMethod"] = "HmacSHA256"
query["SignatureVersion"] = "2"
return aws.call(action, query, callback);
}
return obj;
}
return createELBClient;
}

0 comments on commit edc8c61

Please sign in to comment.