Infra & Cloud terraform Intermediate

AWS SQS Queue with DLQ

Terraform for an SQS queue with a dead-letter queue for failed message handling.

terraform
resource "aws_sqs_queue" "dlq" {
  name = "${var.name}-dlq"
  message_retention_seconds = 1209600
}

resource "aws_sqs_queue" "main" {
  name                        = var.name
  visibility_timeout_seconds  = 30
  redrive_policy = jsonencode({
    deadLetterTargetArn = aws_sqs_queue.dlq.arn
    maxReceiveCount     = 5
  })
}

Prerequisites

  • terraform >= 1.0
  • AWS provider

Pro Tips

  • → Set CloudWatch alarm on dlq ApproximateNumberOfMessages.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
terraform
Level
Intermediate
Read time
3 min
Published
Nov 2025
License
Commercial License

Newsletter

New modules every week, directly to your inbox.