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.
import{Queue}from'@aws-cdk/aws-sqs';exportclassMyStackextendscdk.Stack{constructor(scope:cdk.Construct,id:string,props?:cdk.StackProps){super(scope,id,props);// Dead letter queueconstmyDLQ=newQueue(scope,"MyDLQ",);constmyQueue=newQueue(scope,"MyQueue",{// Configure the redrive policy for MyQueuedeadLetterQueue:{maxReceiveCount:4,queue:myDLQ,},});}}
1 2 3 4 5 6 7 8 91011
{"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 910
Resources:MyQueue:Type:AWS::SQS::QueueProperties:# Configure the redrive policy for MyQueueRedrivePolicy:|{"deadLetterTargetArn": "arn:aws:sqs:us-east-2:111122224444:my-dlq","maxReceiveCount": 4}
1 2 3 4 5 6 7 8 91011
resources:Resources:MyQueue:Type:AWS::SQS::QueueProperties:# Configure the redrive policy for MyQueueRedrivePolicy:|{"deadLetterTargetArn": "arn:aws:sqs:us-east-2:111122224444:my-dlq","maxReceiveCount": 4}
1234567
resource"aws_sqs_queue""this"{ # Configure the redrive policy for the queueredrive_policy=jsonencode({deadLetterTargetArn="arn:aws:sqs:us-east-2:111122224444:my-dlq"maxReceiveCount=4})}