Warning: Serverless doesn't support yet SQS for DLQ. After the deployment on AWS, the DLQ needs to be set on AWS (either manually or by a script).
First, ensure to have serverless-offline-sqs included in your project:
npm install serverless-offline-sqs serverless-offline-sqs-dlq
Then inside your project's
serverless.yml file, add following entries to the plugins section before
serverless-offline (and after
serverless-webpack if presents).
plugins:- serverless-webpack- serverless-offline-sqs- serverless-offline-sqs-dlq- serverless-offline
functions:basicLambda:handler: index.basicLambdaevents:- sqs: arn:aws:sqs:eu-west-1:XXXXXXX:basicLambdaTriggerQueuehandleErrorLambda:handler: index.handleErrorLambdaevents:- sqs: arn:aws:sqs:eu-west-1:XXXXXXX:handleErrorLambdaQueue
Specify in the
custom section which function handles errors:
custom:(...)serverless-offline-sqs-dlq:basicLambda:onError: handleErrorLambdamaxReceiveCount: 3