AWS Cloud Architecture•Part 5: Security, IAM, Messaging & Enterprise Deployments (51 - 65)
SQS Dead-Letter Queue (DLQ).
In Simple Words:
A secondary queue where failed messages are automatically moved after a consumer fails to process them after maxReceiveCount attempts. Prevents "poison pill" messages from clogging the main queue and allows engineers to inspect and replay errors.
hcl
resource "aws_sqs_queue" "main_queue" {
name = "orders-queue"
redrive_policy = jsonencode({
deadLetterTargetArn = aws_sqs_queue.dlq.arn
maxReceiveCount = 3 # Move to DLQ after 3 failures
})
}