npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@osoverflow/serverless-plugin-lambda-dead-letter

v1.0.2

Published

serverless plugin that can configure a lambda with a dead letter queue or topic. From the repo Kayyow/serverless-plugin-lambda-dead-letter and https://github.com/digitalmaas/serverless-plugin-lambda-dead-letter#readme

Downloads

43

Readme

Serverless Lambda Dead Letter Queue Plugin

serverless NPM version digitalmaas NPM downloads standardjs

A Serverless plugin that can assign a dead letter SQS queue to a Lambda function. Works with serverless v1.4+, v2 and v3.

SPECIAL INFORMATION

This package is to include the support for targetArn, written by Kayyow on this pull request: https://github.com/digitalmaas/serverless-plugin-lambda-dead-letter/pull/7

The original package is from @digitalmaas/serverless-plugin-lambda-dead-letter, and when that package includes the pull request, you should move to it.

What is it?

Assigns a DeadLetterConfig to a Lambda function and optionally create a new SQS queue or SNS Topic with a simple syntax.

Failed asynchronous messages for Amazon Lambda can be be sent to an SQS queue or an SNS topic by setting the DeadLetterConfig. Lambda Dead Letter Queues are documented here.

At the time this plugin was developed AWS Cloudformation (and serverless) did not support the DeadLetterConfig property of the Lambda so we have introduced a plugin that calls UpdateFunctionConfiguration on the lambda after serverless deploys the CloudFormation stack.

Installation

From your target serverless project, run:

npm install @digitalmaas/serverless-plugin-lambda-dead-letter --save-dev

Basic Setup

Add the plugin to your serverless.yml:

plugins:
  - '@digitalmaas/serverless-plugin-lambda-dead-letter'

How do I use it?

Dead letter settings are assigned via a new deadLetter property nested under a function in a serverless.yml file.

There are several methods to configure the Lambda deadLetterConfig.

Method-1

DeadLetter Queue

Use the deadLetter.sqs to create a new dead letter queue for the function.

The resulting cloudformation stack will contain an SQS Queue and it's respective QueuePolicy.

Create new dead-letter queue by name

# 'functions' in serverless.yml

functions:
  createUser: # Function name
    handler: handler.createUser # Reference to function 'createUser' in code
    deadLetter:
      sqs:  createUser-dl-queue  # New Queue with this name

Create new dead-letter queue with properties

# 'functions' in serverless.yml

functions:
  createUser: # Function name
    handler: handler.createUser # Reference to function 'createUser' in code
    deadLetter:
      sqs:      # New Queue with these properties
        queueName: createUser-dl-queue
        delaySeconds: 60
        maximumMessageSize: 2048
        messageRetentionPeriod: 200000
        receiveMessageWaitTimeSeconds: 15
        visibilityTimeout: 300

DeadLetter Topic

Use the deadLetter.sns to create a new dead letter topic for the function.

The resulting cloudformation stack will contain an SQS Topic resource.

# 'functions' in serverless.yml

functions:
  createUser: # Function name
    handler: handler.createUser # Reference to function 'createUser' in code

    deadLetter:
      sns:  createUser-dl-topic

Method-2

Use the targetArn property to specify the exact SQS queue or SNS topic to use for Lambda dead letter messages. In this case the queue\topic must already exist as must the queue\topic policy.

Reference the ARN of an existing queue createUser-dl-queue

# 'functions' in serverless.yml

functions:
  createUser: # Function name
    handler: handler.createUser # Reference to function 'createUser' in code

    deadLetter:
      targetArn: arn:aws:sqs:us-west-2:123456789012:createUser-dl-queue

Method-3

If you created a queue\topic in the resource section you can reference it using the GetResourceArn pseudo method.

This will use the arn of the resource referenced by {logicalId}

    deadLetter:
      targetArn:
        GetResourceArn: {logicalId}

Note:

  • At present this only works for SQS queues or SNS Topics.
  • If a queue\topic is created in the resources section you will still need to add a resource for the respective queue\topic policy so that that lambda has permissions to write to the dead letter queue\topic.

In this example the createUser lambda function is using the new CreateUserDeadLetterQueue SQS queue defined in the resources section.

# 'functions' in serverless.yml

functions:
  createUser: # Function name

    handler: handler.createUser # Reference to function 'createUser' in code

    # ...

    deadLetter:
      targetArn:
        GetResourceArn: CreateUserDeadLetterQueue

resources:
    Resources:
      CreateUserDeadLetterQueue:
        Type: AWS::SQS::Queue
        Properties:
          QueueName: create-user-lambda-dl-queue

      CreateUserDeadLetterQueuePolicy:
        Type: AWS::SQS::QueuePolicy
        Properties:
          Queues:
            - Ref: CreateUserDeadLetterQueue

            # Policy properties abbreviated but you need more here ...

Remove DeadLetter Resource

If you previously had a DeadLetter target and want to remove it such that there is no dead letter queue or topic you can supply the deadLetter object with an empty targetArn. Upon deploy the plugin will run the Lambda UpdateFunctionConfiguration and set an empty TargetArn.

# 'functions' in serverless.yml

functions:
  createUser: # Function name

    handler: handler.createUser # Reference to function 'createUser' in code

    # ...

    # Set an empty targetArn to erase previous DLQ settings.
    deadLetter:
      targetArn:

License

MIT License.

This project has been forked from the original serverless-plugin-lambda-dead-letter and published under a different name, as the original has been abandoned.

For the complete information, please refer to the license file.