Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

550
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda