Gohawks
Gohawks

Reputation: 491

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?

Upvotes: 3

Views: 4838

Answers (1)

Deiv
Deiv

Reputation: 3097

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.

Upvotes: 3

Related Questions