I am having a lambda function for which I want to create an SQS dead letter queue. I started by creating the SQS in terraform:
resource "aws_sqs_queue" "my_lambda_dlq" {
name = "my_lambda_dlq"
delay_seconds = 90
max_message_size = 2048
message_retention_seconds = 86400
receive_wait_time_seconds = 10
redrive_policy = jsonencode({
deadLetterTargetArn = aws_sqs_queue.terraform_queue_deadletter.arn
maxReceiveCount = 4
})
tags = local.default_tags
}
This is the example from terraform. However, I got stuck at redrive_policy.
I was not able to find any best practices regarding this. Does anyone have any experience with this?
My main goal here is not to loose any messages. Thanks, Luminita
By specifying a redrive_policy
you configure where the unprocessable / failing messages are supposed to be sent to. The queue where you send these messages to is called dlq / dead-letter-queue, but it will still be a normal queue.
And yes, a DLQ can once again have another DLQ since every DLQ itself is still just a queue. I cannot think of any situation where you would want to have that but nothing is stopping you from doing it.
"If I set redrive_policy, that implies I am setting a DLQ on a DLQ" - technically a dlq does not exist, AWS only knows queues. By having one queue configured as the other's dlq you do not change that both are queues. Any queue is a DLQ if it is configured as the redrive target of any other queue.