Getting lambda response when calling lambda through SQS

I have the following pipeline:

Script –> SQS –> Lambda

  • A script sends a message to a SQS queue.
  • Based on the content of this message, the Lambda executes a different process (Calls an API with some payload)
  • The script needs to receive the API HTTP response, output of Lambda.

How can I achieve this last step? (Ideally using boto3)

>Solution :

You can’t / don’t. If you want a response from the lambda invoke the lambda directly and synchronously. Putting a queue between you and the lambda explicitly decouples your script from the lambda.

You could include some path / identifier in the message which tells the lambda where to put the response, e.g. under what dynamodb entry or into which S3 key. And then your script would need to poll that target location for an update from the lambda.

Leave a Reply