Published a Lambda Dead Letter Queue Plugin



I’ve just created a plugin: serverless-plugin-lambda-dead-letter that can create a new dead letter queue (or topic) and attach it to a Lambda’s DeadLetterConfig.

Unfortunately this is not supported in CloudFormation at this time so I’ve created the plugin to fill in the gaps.

The plugin can set the Lambda function’s DeadLetterConfig.TargetArn with one of the following:

  • A newly created queue/topic created with simple syntax in the plugin’s deadLetter.sqs or deadLetter.sns properties.
  • A pre-existing queue/topic using an arn
  • A queue/topic created in manually in the Resources section of the serverless.yml

This is helpful if you want to have more fault tolerant event handling.

In one case I’ve used it more as a retry mechanism:

  1. Configure lambda with a deadLetter setup so failed events are forwarded to sqs.
  2. Set a scheduled event on the lambda with logic to retry events on the queue.
  3. Lambda has an internal unwrapping mechanism to handle events that were:
  • Sent directly
  • Sent via SNS
  • Pulled from retry queue during a scheduled event.

Lambda onError can't use CloudFormation "Ref", requires ARN string?