About
Amazon Web Services node.js module. Currently under development. This is basically a fork of aws-lib which served as most of the inspiration for this module. While it resembles its original structure, some of the internal workings are changed due to obvious reasons.
Installation
Either manually clone this repository into your node_modules directory, or the recommended method:
npm install aws2js
Design goals
- HTTPS-only APIs communication
- Proper error reporting
- Simple to write clients for a specific AWS service
- Simple to use AWS API calls
For example, the EC2 client, as implemented into the library is just:
exports.ec2 = client({
prefix: 'ec2',
path: '/',
query: {
Version: '2011-05-15',
SignatureMethod: 'HmacSHA256',
SignatureVersion: '2'
}
});
Abstracting most of the AWS APIs plumbing is the actual goal behind the client simplicity.
Supported services
- EC2 (require('aws2js').ec2)
- RDS (require('aws2js').rds)
More will come. Remember, this is under active development, but an early release. I still need S3 support (at least) for my own usage.
Usage mode
var ec2 = require('aws2js').ec2;
ec2.setCredentials('accessKeyId', 'secretAccessKey'); // Mandatory.
ec2.setRegion('eu-east-1'); // Optional. The us-east-1 region is the default API entry point anyway.
// action, query, callback - for the action and query parameters, check the EC2 API reference.
ec2.call('DescribeVolumes', {}, function (error, response) {
if ( ! error) {
for (var i in response.volumeSet.item) {
console.log(response.volumeSet.item[i]);
}
} else {
console.error(error);
}
});
A config() method is provided for the service client. You may invoke it as:
ec2.config({
accessKeyId: 'accessKeyId',
secretAccessKey: 'secretAccessKey',
host: 'ec2.us-west-1.amazonaws.com'
});
This is the equivalent of calling setCredentials() and setRegion() but it is more verbose and error prone. However, it may change the internals of the service client, therefore usable for fine tuning the service client at a lower level if a direct approach via implemented properties isn't available.
The returned error into the callback is an Error instance. If it's an error generated by the AWS API itself, the response argument contains the raw object returned by the AWS API. Currently there isn't implemented a method to get the actual error message from the response error due to the fact that the AWS APIs don't use a standardized format for all the APIs. Implementing the errors specifications into the service client is planned.