aws-promjs v0.1.3
AWS-PromJS
AWS SDK wrapper which converts the standard AWS API Service methods into functions which will return a promise rather than take a callback. The Service objects are decorated based off a list of names in and can be easily extended or overwritten. So, what is the difference between AWS-PromJS and other modules that that wrap AWS Service methods to return a promise? Not much except for:
- The names are the same! The AWS methods names your used to, no changes!
- Explicit control through config of which methods return a promise and which don't.
- Your setup and AWS configuration doesn't change. It should be identical to your old code. Only service object methods return promises.
- If AWS-PromJS doesn't support the Service object your using, just add the service object namespace into
inc/aws-promjs.jsonwith an Array containing every method name, or create your own config file in project root/aws-promjs.json.- If you don't want a promise returned from a specific method, add that method name to an Array under `exclude <service-name> in a config file.
// Require 'aws-promjs' instead of 'aws-sdk'.
var AWS = require('aws-promjs');
// Configuration code should work exactly as AWS.
AWS.config.loadFromPath('./path/to/AWS/config.json');
AWS.config.region = 'us-east-1';
// Service creation is the same as AWS.
var s3 = new AWS.S3();
// Service method names the same as AWS!
s3.createBucket({Bucket: 'Quite spiffy ole chap'})
// except that they return a promise rather than use callbacks
.then(function(data) {
console.log('promise resolved', data)
})
.catch(function(err) {
console.log('promise failed', err);
});This is a list of all the services returning promises out of the box and their version numbers. Most of these are untested at the moment and I could use some help finding any issues. If there is a service not listed here, it will still work the same as it did without aws-promjs. If you want to add a service that is not listed here, just follow the same convention used in the ./inc/aws-promjs.json file, but do so in your own aws-promjs.json file within your projects root directory so it doesn't get overwritten on update.
AutoScalingversion:[2011-01-01].CloudFormationversion:[2010-05-15].CloudFrontversion:[2014-10-21].CouldSearchversion:[2013-01-01].CloudSearchDomainversion:[2013-01-01].CloudWatchversion:[2010-08-01].CloudWatchLogsversion:[2014-03-28].CognitoIdentityversion:[2014-06-30].CognitoSyncversion:[2014-06-30].DynamoDBversion:[2012-08-10].EC2version:[2014-10-01].ECSversion:[2014-11-13].EMRversion:[2009-03-31].ElasticTranscoderversion:[2012-09-25].ElastiCacheversion:[2014-09-30].Glacierversion:[2012-06-01].Kinesisversion:[2013-12-02].Redshiftversion:[2012-12-01].RDSversion:[2014-09-01].Route53version:[2013-04-01].Route53Domainsversion:[2014-05-15].SESversion:[2010-12-01].SNSversion:[2010-03-31].SQSversion:[2012-11-05].S3version:[2006-03-01]
Footnotes
Note:
- The config json files are not asyncronous because if they were then we wouldn't be able to return the AWS object using the same API as AWS-SDK. This may change in the future, rather than immediately return the AWS main object from
require('aws-promjs')it may be better to return a promise there as well. I want to see how the promises in the service namespaces work out first.
Feel free to contribute lists of method names
Since you should only need a list of the method names in an AWS Service object to convert it. If you compile a list of all the method names in an object feel free to send it over to mrosata1984@gmail.com and I will try to add it.