Created
January 19, 2017 21:38
-
-
Save justengland/94d8b4d84f4652ee373d03c68bd13518 to your computer and use it in GitHub Desktop.
Add promises to AWS methids
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cloudformation = new AWS.CloudFormation(); | |
const describeStacks = promisifyAWS(cloudformation, 'describeStacks'); | |
// Issue with AWS Code structure. | |
// Not bening fixed, but this should work for the methods I have seen. | |
// https://github.com/aws/aws-sdk-js/issues/278 | |
function promisifyAWS(service, method) { | |
return function(params) { | |
return new Promise(function (resolve, reject) { | |
service[method](params, function (err, data) { | |
if (err) { | |
reject(err); | |
return; | |
} | |
resolve(data); | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure if this is the best code in the world, but it works and I can stop thinking about it.