All Projects → gmetzker → serverless-plugin-lambda-dead-letter

gmetzker / serverless-plugin-lambda-dead-letter

Licence: MIT License
serverless plugin that can configure a lambda with a dead letter queue or topic

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to serverless-plugin-lambda-dead-letter

Serverless Appsync Plugin
serverless plugin for appsync
Stars: ✭ 804 (+1814.29%)
Mutual labels:  lambda, serverless-plugin
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (+21.43%)
Mutual labels:  lambda, serverless-plugin
Serverless Bundle
Optimized packages for ES6 and TypeScript Node.js Lambda functions without any configuration.
Stars: ✭ 295 (+602.38%)
Mutual labels:  lambda, serverless-plugin
Serverless Layers
Serverless.js plugin that implements AWS Lambda Layers which reduces drastically lambda size, warm-up and deployment time.
Stars: ✭ 119 (+183.33%)
Mutual labels:  lambda, serverless-plugin
serverless-plugin-parcel
A Serverless framework plugin to bundle assets with Parcel (ES6/7 or Typescript)
Stars: ✭ 23 (-45.24%)
Mutual labels:  lambda, serverless-plugin
serverless-plugin-bespoken
⚡ Serverless plugin to use our bst proxy tool
Stars: ✭ 29 (-30.95%)
Mutual labels:  lambda, serverless-plugin
Serverless Plugin Warmup
Keep your lambdas warm during winter. ♨
Stars: ✭ 814 (+1838.1%)
Mutual labels:  lambda, serverless-plugin
Serverless Chrome
🌐 Run headless Chrome/Chromium on AWS Lambda
Stars: ✭ 2,625 (+6150%)
Mutual labels:  lambda, serverless-plugin
serverless-certificate-creator
serverless plugin to manage the certificate of your lambdas custom domain (API Gateway=
Stars: ✭ 33 (-21.43%)
Mutual labels:  lambda, serverless-plugin
serverless-plugin-epsagon
Epsagon's plugin for Serverless Framework ⚡️
Stars: ✭ 53 (+26.19%)
Mutual labels:  lambda, serverless-plugin
super-serverless-sample
Backend serverless que simula o sistema de votação do BBB
Stars: ✭ 30 (-28.57%)
Mutual labels:  lambda, sqs-queue
twitter
A serverless social network that's under development with some cool stuff, such as Serverless Framework, AppSync, GraphQL, Lambda, DynamoDB, Cognito, Kinesis Firehose, and Algolia ☁️
Stars: ✭ 29 (-30.95%)
Mutual labels:  lambda
0x4447 product answering machine
☎️ An automated answering machine build on top of Amazon Connect
Stars: ✭ 38 (-9.52%)
Mutual labels:  lambda
lambda-redirector
Redirect an entire website using AWS Lambda
Stars: ✭ 21 (-50%)
Mutual labels:  lambda
serverless-ninja
Code repository of AWS Serverless Ninja Guidebook 👹 👹 👹
Stars: ✭ 40 (-4.76%)
Mutual labels:  lambda
cerberus-serverless-components
A collection of AWS Serverless components for Cerberus
Stars: ✭ 12 (-71.43%)
Mutual labels:  lambda
spotify-lambda
λ🎵AWS Lambda functions for Spotify tracking
Stars: ✭ 12 (-71.43%)
Mutual labels:  lambda
pinboard-backup
This backs up Pinboard bookmarks to DynamoDB.
Stars: ✭ 17 (-59.52%)
Mutual labels:  lambda
nuxt-on-lambda
Nuxt.jsをAWS Lambdaで動かす
Stars: ✭ 78 (+85.71%)
Mutual labels:  lambda
terraform-provider-bless
Terraform provider to automate the creation of BLESS deployments
Stars: ✭ 12 (-71.43%)
Mutual labels:  lambda

Serverless Plugin: Lambda DeadLetterConfig

serverless npm version

Build Status Coverage Status dependencies Status devDependencies Status

What is it?

A serverless plugin that can assign 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

Requirements

  • nodeJs > v4.0
  • serverless > v1.4

Install the plugin.

npm install serverless-plugin-lambda-dead-letter

Install the plugin with npm and reference it in the serverless yaml file as documented here.

# serverless.yml file

plugins:
  - 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:
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].