aws.sqs.RedrivePolicy
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
using System.Collections.Generic;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var queue = new Aws.Sqs.Queue("queue");
var ddl = new Aws.Sqs.Queue("ddl", new()
{
RedriveAllowPolicy = queue.Arn.Apply(arn => JsonSerializer.Serialize(new Dictionary<string, object?>
{
["redrivePermission"] = "byQueue",
["sourceQueueArns"] = new[]
{
arn,
},
})),
});
var redrivePolicy = new Aws.Sqs.RedrivePolicy("redrivePolicy", new()
{
QueueUrl = queue.Id,
RedrivePolicyName = ddl.Arn.Apply(arn => JsonSerializer.Serialize(new Dictionary<string, object?>
{
["deadLetterTargetArn"] = arn,
["maxReceiveCount"] = 4,
})),
});
});
package main
import (
"encoding/json"
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/sqs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
queue, err := sqs.NewQueue(ctx, "queue", nil)
if err != nil {
return err
}
ddl, err := sqs.NewQueue(ctx, "ddl", &sqs.QueueArgs{
RedriveAllowPolicy: queue.Arn.ApplyT(func(arn string) (pulumi.String, error) {
var _zero pulumi.String
tmpJSON0, err := json.Marshal(map[string]interface{}{
"redrivePermission": "byQueue",
"sourceQueueArns": []string{
arn,
},
})
if err != nil {
return _zero, err
}
json0 := string(tmpJSON0)
return pulumi.String(json0), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
_, err = sqs.NewRedrivePolicy(ctx, "redrivePolicy", &sqs.RedrivePolicyArgs{
QueueUrl: queue.ID(),
RedrivePolicy: ddl.Arn.ApplyT(func(arn string) (pulumi.String, error) {
var _zero pulumi.String
tmpJSON1, err := json.Marshal(map[string]interface{}{
"deadLetterTargetArn": arn,
"maxReceiveCount": 4,
})
if err != nil {
return _zero, err
}
json1 := string(tmpJSON1)
return pulumi.String(json1), nil
}).(pulumi.StringOutput),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.sqs.Queue;
import com.pulumi.aws.sqs.QueueArgs;
import com.pulumi.aws.sqs.RedrivePolicy;
import com.pulumi.aws.sqs.RedrivePolicyArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var queue = new Queue("queue");
var ddl = new Queue("ddl", QueueArgs.builder()
.redriveAllowPolicy(queue.arn().applyValue(arn -> serializeJson(
jsonObject(
jsonProperty("redrivePermission", "byQueue"),
jsonProperty("sourceQueueArns", jsonArray(arn))
))))
.build());
var redrivePolicy = new RedrivePolicy("redrivePolicy", RedrivePolicyArgs.builder()
.queueUrl(queue.id())
.redrivePolicy(ddl.arn().applyValue(arn -> serializeJson(
jsonObject(
jsonProperty("deadLetterTargetArn", arn),
jsonProperty("maxReceiveCount", 4)
))))
.build());
}
}
import pulumi
import json
import pulumi_aws as aws
queue = aws.sqs.Queue("queue")
ddl = aws.sqs.Queue("ddl", redrive_allow_policy=queue.arn.apply(lambda arn: json.dumps({
"redrivePermission": "byQueue",
"sourceQueueArns": [arn],
})))
redrive_policy = aws.sqs.RedrivePolicy("redrivePolicy",
queue_url=queue.id,
redrive_policy=ddl.arn.apply(lambda arn: json.dumps({
"deadLetterTargetArn": arn,
"maxReceiveCount": 4,
})))
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const queue = new aws.sqs.Queue("queue", {});
const ddl = new aws.sqs.Queue("ddl", {redriveAllowPolicy: queue.arn.apply(arn => JSON.stringify({
redrivePermission: "byQueue",
sourceQueueArns: [arn],
}))});
const redrivePolicy = new aws.sqs.RedrivePolicy("redrivePolicy", {
queueUrl: queue.id,
redrivePolicy: ddl.arn.apply(arn => JSON.stringify({
deadLetterTargetArn: arn,
maxReceiveCount: 4,
})),
});
resources:
queue:
type: aws:sqs:Queue
ddl:
type: aws:sqs:Queue
properties:
redriveAllowPolicy:
fn::toJSON:
redrivePermission: byQueue
sourceQueueArns:
- ${queue.arn}
redrivePolicy:
type: aws:sqs:RedrivePolicy
properties:
queueUrl: ${queue.id}
redrivePolicy:
fn::toJSON:
deadLetterTargetArn: ${ddl.arn}
maxReceiveCount: 4
Create RedrivePolicy Resource
new RedrivePolicy(name: string, args: RedrivePolicyArgs, opts?: CustomResourceOptions);
@overload
def RedrivePolicy(resource_name: str,
opts: Optional[ResourceOptions] = None,
queue_url: Optional[str] = None,
redrive_policy: Optional[str] = None)
@overload
def RedrivePolicy(resource_name: str,
args: RedrivePolicyArgs,
opts: Optional[ResourceOptions] = None)
func NewRedrivePolicy(ctx *Context, name string, args RedrivePolicyArgs, opts ...ResourceOption) (*RedrivePolicy, error)
public RedrivePolicy(string name, RedrivePolicyArgs args, CustomResourceOptions? opts = null)
public RedrivePolicy(String name, RedrivePolicyArgs args)
public RedrivePolicy(String name, RedrivePolicyArgs args, CustomResourceOptions options)
type: aws:sqs:RedrivePolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RedrivePolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args RedrivePolicyArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args RedrivePolicyArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RedrivePolicyArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RedrivePolicyArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
RedrivePolicy Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The RedrivePolicy resource accepts the following input properties:
- Queue
Url string The URL of the SQS Queue to which to attach the policy
- Redrive
Policy stringName The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- Queue
Url string The URL of the SQS Queue to which to attach the policy
- Redrive
Policy string The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- queue
Url String The URL of the SQS Queue to which to attach the policy
- redrive
Policy String The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- queue
Url string The URL of the SQS Queue to which to attach the policy
- redrive
Policy string The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- queue_
url str The URL of the SQS Queue to which to attach the policy
- redrive_
policy str The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- queue
Url String The URL of the SQS Queue to which to attach the policy
- redrive
Policy String The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
Outputs
All input properties are implicitly available as output properties. Additionally, the RedrivePolicy resource produces the following output properties:
- Id string
The provider-assigned unique ID for this managed resource.
- Id string
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
- id string
The provider-assigned unique ID for this managed resource.
- id str
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
Look up Existing RedrivePolicy Resource
Get an existing RedrivePolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: RedrivePolicyState, opts?: CustomResourceOptions): RedrivePolicy
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
queue_url: Optional[str] = None,
redrive_policy: Optional[str] = None) -> RedrivePolicy
func GetRedrivePolicy(ctx *Context, name string, id IDInput, state *RedrivePolicyState, opts ...ResourceOption) (*RedrivePolicy, error)
public static RedrivePolicy Get(string name, Input<string> id, RedrivePolicyState? state, CustomResourceOptions? opts = null)
public static RedrivePolicy get(String name, Output<String> id, RedrivePolicyState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Queue
Url string The URL of the SQS Queue to which to attach the policy
- Redrive
Policy stringName The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- Queue
Url string The URL of the SQS Queue to which to attach the policy
- Redrive
Policy string The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- queue
Url String The URL of the SQS Queue to which to attach the policy
- redrive
Policy String The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- queue
Url string The URL of the SQS Queue to which to attach the policy
- redrive
Policy string The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- queue_
url str The URL of the SQS Queue to which to attach the policy
- redrive_
policy str The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
- queue
Url String The URL of the SQS Queue to which to attach the policy
- redrive
Policy String The JSON redrive policy for the SQS queue. Accepts two key/val pairs:
deadLetterTargetArn
andmaxReceiveCount
. Learn more in the Amazon SQS dead-letter queues documentation.
Import
SQS Queue Redrive Policies can be imported using the queue URL, e.g.,
$ pulumi import aws:sqs/redrivePolicy:RedrivePolicy test https://queue.amazonaws.com/0123456789012/myqueue
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
aws
Terraform Provider.