I have attempted to follow the documentation about setting up an SQS Dead Letter Queue for my Lambda on AWS but I can't seem to get the errors to pass through to it.
I have a Lambda on eu-west-2
exports.handler = async (event) => {
if (event.desire === 'error') {
throw new Error('dutifully throw an error');
}
const response = {
statusCode: 200,
body: JSON.stringify('Complete the lambda!'),
};
return response;
};
with asynchronous invocation set to my sqs queue test-dlq
I've added the following into the role:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Action": "sqs:*",
"Resource": "arn:aws:sqs:eu-west-2:123456789:test-dlq"
}
]
}
(I've previously had this set to "Action": "sqs:SendMessage"
but have made it more permissive for brevity)
And I've setup my SQS Queue to receive the messages:
My test case payload is:
{
"desire": "error"
}
which causes the lambda to error and add the error to the CloudWatch log but doesn't pass to the DLQ.
Do I need to do anything to route the errors to the Queue or have I misconfigured this please?
aws lambda invoke --function-name testFunction --payload '{"desire":"error"}' /tmp/out.json
– obie