mardi 30 décembre 2014

How do you structure sequential AWS service calls within lambda given all the calls are asynchronous?

I'm coming from a java background so a bit of a newbie on Javascript conventions needed for Lambda.


I've got a lambda function which is meant to do several AWS tasks in a particular order, depending on the result of the previous task.


Given that each task reports its results asynchronously, I'm wondering if the right way make sure they all happen in the right sequence, and the results of one operation are available to the invocation of the next function.


It seems like I have to invoike each function in the callback of the prior function, but seems like that will some kind of deep nesting and wondering if that is the proper way to do this.


For example on of these functions requires a DynamoDB getItem, following by a call to SNS to get an endpoint, followed by a SNS call to send a message, followed by a DynamoDB write.


What's the right way to do that in lambda javascript, accounting for all that asynchronicity?





Aucun commentaire:

Enregistrer un commentaire