Skip to content

SQS Redrive Policy

Level: Error

Initial version: 0.1.7

cfn-lint: ES6000

tflint: aws_sqs_queue_redrive_policy

You can configure the redrive policy on an Amazon SQS queue. With a redrive policy, you can define how many times SQS will make the messages available for consumers. After that, SQS will send it to the dead-letter queue specified in the policy.

Disabled for Terraform

This rule is disabled for Terraform, as the current linter only support static values in expressions. See this issue for more information.

Implementations

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { Queue } from '@aws-cdk/aws-sqs';

export class MyStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    // Dead letter queue
    const myDLQ = new Queue(
      scope, "MyDLQ",
    );

    const myQueue = new Queue(
      scope, "MyQueue",
      {
        // Configure the redrive policy for MyQueue
        deadLetterQueue: {
          maxReceiveCount: 4,
          queue: myDLQ,
        },
      }
    );
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "Resources": {
    "MyQueue": {
      "Type": "AWS::SQS::Queue",
      "Properties": {
        // Configure the redrive policy for MyQueue
        "RedrivePolicy": "{ \"deadLetterTargetArn\": \"arn:aws:sqs:us-east-2:111122224444:my-dlq\", \"maxReceiveCount\": 4 }"
      }
    }
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Resources:
  MyQueue:
    Type: AWS::SQS::Queue
    Properties:
      # Configure the redrive policy for MyQueue
      RedrivePolicy: |
        {
          "deadLetterTargetArn": "arn:aws:sqs:us-east-2:111122224444:my-dlq",
          "maxReceiveCount": 4
        }
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
resources:
  Resources:
    MyQueue:
      Type: AWS::SQS::Queue
      Properties:
        # Configure the redrive policy for MyQueue
        RedrivePolicy: |
          {
            "deadLetterTargetArn": "arn:aws:sqs:us-east-2:111122224444:my-dlq",
            "maxReceiveCount": 4
          }
1
2
3
4
5
6
7
resource "aws_sqs_queue" "this" {
  # Configure the redrive policy for the queue
  redrive_policy = jsonencode({
    deadLetterTargetArn = "arn:aws:sqs:us-east-2:111122224444:my-dlq"
    maxReceiveCount     = 4
  })
}

See also