andrew-templeton / cfn-lambda

CloudFormation custom resource helper for Lambda Node.js runtime
MIT License
82 stars 22 forks source link

Added support for async functions #38

Closed Davidster closed 5 years ago

Davidster commented 5 years ago

Hello @andrew-templeton

I noticed that if I were to mark my handler functions as async and then wait for a promise to resolve before calling the reply() callback, then the Lambda execution would actually stop before the S3 PUT request finishes. As I'm sure you know, the consequences of this are quite annoying to deal with.

I have attempted to fix the issue by wrapping the async function into a normal function that uses then and catch to invoke the reply callback appropriately. From my testing so far it seems to be working. I also added a section to the docs explaining how to use this async function support feature.

Thank you very much for this repository ! It was very useful to me while developing a project of my own with custom resources. Once I put my project up on Github, I hope you would consider adding me to the list of source code examples in the README.

:smile:

andrew-templeton commented 5 years ago

@Davidster - Once you add your resource, add a PR for putting it on the list! Thanks for the contribution to the docs / accepting it.

My manual testing suggests that this will work. Would you mind adding tests for it so I can accept it and put it into a new release?

Davidster commented 5 years ago

@andrew-templeton okay, will do.

Davidster commented 5 years ago

@andrew-templeton updated