简体   繁体   中英

Why my failed event is not sent to AWS Dead Letter Queue DLQ?

I am trying to set up DLQ to capture failed events from Lambda function.

Here is what I have done:

  1. Created a DeadLetterQueue (QueueX) in SQS,
  2. Set my lambda function DLQ resource to 'Amazon SQS'
  3. Set SQS Queue to QueueX
  4. Created a Policy to give all permissions (sqs:*) to all resources (*); VisibilityTimeout=5 mins, MessageRetentionPeriod=3 days
  5. Attach the policy to the role which executes the lambda function

Now via ' Queue Actions ', I can send a message and see it show up in "Messages Available". But if I send a http request to the lambda function - I purposely created a malformed JSON whose exception is not caught - I saw the error message in CloudWatch but nothing sent to QueueX.

What am I missing?

According to your latest comment:

testing by posting a HTTP request from Postman directly to Api gateway for the lambda

This is the cause of the issue you are facing.

To explain, when you have an API gateway proxy to Lambda, API gateway handles the error cases that Lambda sends back (instead of the Lambda service itself, which has the DLQ configuration), and the errors will not end up in DLQ. In order to implement a DLQ, you need a different design, potentially something like calls going to SNS -> Lambda, and then on fail Lambda will send those messages to DLQ.

You might also be able to fix this if you don't have a proxy integration, but I haven't tested that out personally and I don't know for sure if this will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM