Skip to content

Resource: awsSqsQueueRedrivePolicy

Allows you to set a redrive policy of an SQS Queue while referencing ARN of the dead letter queue inside the redrive policy.

This is useful when you want to set a dedicated dead letter queue for a standard or FIFO queue, but need the dead letter queue to exist before setting the redrive policy.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.sqsQueue.SqsQueue(this, "ddl", {
  name: "examplequeue-ddl",
  redriveAllowPolicy:
    '${jsonencode({\n    redrivePermission = "byQueue",\n    sourceQueueArns   = [aws_sqs_queue.q.arn]\n  })}',
});
const awsSqsQueueQ = new aws.sqsQueue.SqsQueue(this, "q", {
  name: "examplequeue",
});
const awsSqsQueueRedrivePolicyQ =
  new aws.sqsQueueRedrivePolicy.SqsQueueRedrivePolicy(this, "q_2", {
    queueUrl: awsSqsQueueQ.id,
    redrivePolicy:
      "${jsonencode({\n    deadLetterTargetArn = aws_sqs_queue.ddl.arn\n    maxReceiveCount     = 4\n  })}",
  });
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsSqsQueueRedrivePolicyQ.overrideLogicalId("q");

Argument Reference

The following arguments are supported:

  • queueUrl - (Required) The URL of the SQS Queue to which to attach the policy
  • redrivePolicy - (Required) The JSON redrive policy for the SQS queue. Accepts two key/val pairs: deadLetterTargetArn and maxReceiveCount. Learn more in the Amazon SQS dead-letter queues documentation.

Attributes Reference

No additional attributes are exported.

Import

SQS Queue Redrive Policies can be imported using the queue URL, e.g.,

$ terraform import aws_sqs_queue_redrive_policy.test https://queue.amazonaws.com/0123456789012/myqueue