title: Trigger AWS Lambda after SQS has received message from SNS
body: <p>I am facing the problem of how to trigger a Lambda function after a message has been written in a SQS queue which is a SNS subscriber.</p>
  
  <p>I know there is <a href="https://stackoverflow.com/questions/30459682/invoke-aws-lambda-sns-event-only-after-sqs-subscription-on-same-topic-has-been-p">this</a> useful post but I have not really understood how to publish a second message (on topic B) after the first one has been successfully sent (on topic A). I did not know if it is the right answer.</p>
  
  <p>Here below there is a diagram of what I would link to implement</p>
  
  <p><a href="https://i.stack.imgur.com/VDkAR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VDkAR.png" alt="enter image description here"></a></p>
  
  <p>As you can see there is an API which publish to an SNS topic. The subscribers of this topic should be:</p>
  
  <ol>
  <li>An SQS queue where a message is stored</li>
  <li>A Lambda function which has to been triggered by SNS to consume the message written to the queue.</li>
  </ol>
  
  <p>The problem I am facing is how to be sure the lambda is executed after a message has been written in the queue and how to really implement the solution.
  How to publish two topic and from one writing message in SQS and from the other one trigger the queue (how can be sure the message has been effectively written in the queue?).</p>
  
  <p>Thank you very much guys,
  hope I was clear enough.</p>