Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

555
Vistas
Serverless Framework how to create an AWS SQS DeadLetter queue?

I am trying to create an AWS SQS Dead Letter Queue, using the serverless framework
The idea is to have a SQS to trigger a Lambda function,
and have another SQS as a DeadLetterQueue, ie. to pick up the message in case the Lambda fails or timesout

I did the following to create a test project -

mkdir dlq
cd dlq/
serverless create --template aws-nodejs

Following is my serverless.yaml -

service: dlq

provider:
  name: aws
  runtime: nodejs12.x
  region: ap-southeast-1
  role: arn:aws:iam::xxxx:role/dlqLambdaRole

plugins:
  - serverless-plugin-lambda-dead-letter

functions:
  dlq:
    handler: handler.hello
    events:
      - sqs:
          arn:
            Fn::GetAtt:
              - MainQueue
              - Arn

    deadLetter:
      targetArn:
        GetResourceArn: DeadLetterQueue

resources:
    Resources:  
        MainQueue:
            Type: AWS::SQS::Queue
            Properties:
                QueueName: main
        DeadLetterQueue:
            Type: AWS::SQS::Queue
            Properties:
                QueueName: dlq

I also tried the following -

service: dlq

provider:
  name: aws
  runtime: nodejs12.x
  region: ap-southeast-1
  role: arn:aws:iam::xxxx:role/dlqLambdaRole

plugins:
  - serverless-plugin-lambda-dead-letter

functions:
  dlq:
    handler: handler.hello
    events:
      - sqs:
          arn:
            Fn::GetAtt:
              - MainQueue
              - Arn

    deadLetter:
      sqs: dlq

resources:
    Resources:
      MainQueue:
        Type: AWS::SQS::Queue
        Properties:
          QueueName: main

But in both these cases, the framework is just creating a normal SQS

I am following this document -
https://www.serverless.com/plugins/serverless-plugin-lambda-dead-letter

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Better late than never. Hope this helps you or someone searching for this problem.

When you configure SQS to trigger Lambda, the DLQ is supposed to be configured on the SQS(Since it would not be an Asynchronous invocation). Notice the 'Note' section in the link Source

Hence your serverless.yaml needs to declare the ReddrivePolicy in the main queue to refer to the DLQ. (Below)

service: dlq

provider:
  name: aws
  runtime: nodejs12.x
  region: ap-southeast-1
  role: arn:aws:iam::xxxx:role/dlqLambdaRole


functions:
  dlq:
    handler: handler.hello
    events:
      - sqs:
          arn:
            Fn::GetAtt:
              - MainQueue
              - Arn

    deadLetter:
      targetArn:
        GetResourceArn: DeadLetterQueue

resources:
    Resources:  
        MainQueue:
            Type: AWS::SQS::Queue
            Properties:
                QueueName: main
                RedrivePolicy: 
                  deadLetterTargetArn: 
                    Fn::GetAtt: 
                      - "DeadLetterQueue"
                      - "Arn"
                  maxReceiveCount: 5
        DeadLetterQueue:
            Type: AWS::SQS::Queue
            Properties:
                QueueName: dlq

maxReceiveCount is set to 5 as per AWS Documentation.

over 4 years ago · Santiago Trujillo Denunciar

0

To give you some background, Dead Letter Queue is just that, a normal SQS queue. it's the configuration at AWS Lambda that informs it to push message to this Queue whenever there is any error while processing the message.

You can verify this from the management console by referring to the "Dead-letter queue service" under "Asynchronous invocation"

enter image description here

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda