title: How do you structure sequential AWS service calls within lambda given all the calls are asynchronous?
body: <p>I'm coming from a java background so a bit of a newbie on Javascript conventions needed for Lambda.</p>
  
  <p>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.</p>
  
  <p>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.  </p>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>What's the right way to do that in lambda javascript, accounting for all that asynchronicity?</p>