github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/sqs/redrivePolicy.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package sqs
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Allows you to set a redrive policy of an SQS Queue
    16  // while referencing ARN of the dead letter queue inside the redrive policy.
    17  //
    18  // This is useful when you want to set a dedicated
    19  // dead letter queue for a standard or FIFO queue, but need
    20  // the dead letter queue to exist before setting the redrive policy.
    21  //
    22  // ## Example Usage
    23  //
    24  // <!--Start PulumiCodeChooser -->
    25  // ```go
    26  // package main
    27  //
    28  // import (
    29  //
    30  //	"encoding/json"
    31  //
    32  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sqs"
    33  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    34  //
    35  // )
    36  //
    37  //	func main() {
    38  //		pulumi.Run(func(ctx *pulumi.Context) error {
    39  //			q, err := sqs.NewQueue(ctx, "q", &sqs.QueueArgs{
    40  //				Name: pulumi.String("examplequeue"),
    41  //			})
    42  //			if err != nil {
    43  //				return err
    44  //			}
    45  //			ddl, err := sqs.NewQueue(ctx, "ddl", &sqs.QueueArgs{
    46  //				Name: pulumi.String("examplequeue-ddl"),
    47  //				RedriveAllowPolicy: q.Arn.ApplyT(func(arn string) (pulumi.String, error) {
    48  //					var _zero pulumi.String
    49  //					tmpJSON0, err := json.Marshal(map[string]interface{}{
    50  //						"redrivePermission": "byQueue",
    51  //						"sourceQueueArns": []string{
    52  //							arn,
    53  //						},
    54  //					})
    55  //					if err != nil {
    56  //						return _zero, err
    57  //					}
    58  //					json0 := string(tmpJSON0)
    59  //					return pulumi.String(json0), nil
    60  //				}).(pulumi.StringOutput),
    61  //			})
    62  //			if err != nil {
    63  //				return err
    64  //			}
    65  //			_, err = sqs.NewRedrivePolicy(ctx, "q", &sqs.RedrivePolicyArgs{
    66  //				QueueUrl: q.ID(),
    67  //				RedrivePolicy: ddl.Arn.ApplyT(func(arn string) (pulumi.String, error) {
    68  //					var _zero pulumi.String
    69  //					tmpJSON1, err := json.Marshal(map[string]interface{}{
    70  //						"deadLetterTargetArn": arn,
    71  //						"maxReceiveCount":     4,
    72  //					})
    73  //					if err != nil {
    74  //						return _zero, err
    75  //					}
    76  //					json1 := string(tmpJSON1)
    77  //					return pulumi.String(json1), nil
    78  //				}).(pulumi.StringOutput),
    79  //			})
    80  //			if err != nil {
    81  //				return err
    82  //			}
    83  //			return nil
    84  //		})
    85  //	}
    86  //
    87  // ```
    88  // <!--End PulumiCodeChooser -->
    89  //
    90  // ## Import
    91  //
    92  // Using `pulumi import`, import SQS Queue Redrive Policies using the queue URL. For example:
    93  //
    94  // ```sh
    95  // $ pulumi import aws:sqs/redrivePolicy:RedrivePolicy test https://queue.amazonaws.com/0123456789012/myqueue
    96  // ```
    97  type RedrivePolicy struct {
    98  	pulumi.CustomResourceState
    99  
   100  	// The URL of the SQS Queue to which to attach the policy
   101  	QueueUrl pulumi.StringOutput `pulumi:"queueUrl"`
   102  	// 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](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html).
   103  	RedrivePolicy pulumi.StringOutput `pulumi:"redrivePolicy"`
   104  }
   105  
   106  // NewRedrivePolicy registers a new resource with the given unique name, arguments, and options.
   107  func NewRedrivePolicy(ctx *pulumi.Context,
   108  	name string, args *RedrivePolicyArgs, opts ...pulumi.ResourceOption) (*RedrivePolicy, error) {
   109  	if args == nil {
   110  		return nil, errors.New("missing one or more required arguments")
   111  	}
   112  
   113  	if args.QueueUrl == nil {
   114  		return nil, errors.New("invalid value for required argument 'QueueUrl'")
   115  	}
   116  	if args.RedrivePolicy == nil {
   117  		return nil, errors.New("invalid value for required argument 'RedrivePolicy'")
   118  	}
   119  	opts = internal.PkgResourceDefaultOpts(opts)
   120  	var resource RedrivePolicy
   121  	err := ctx.RegisterResource("aws:sqs/redrivePolicy:RedrivePolicy", name, args, &resource, opts...)
   122  	if err != nil {
   123  		return nil, err
   124  	}
   125  	return &resource, nil
   126  }
   127  
   128  // GetRedrivePolicy gets an existing RedrivePolicy resource's state with the given name, ID, and optional
   129  // state properties that are used to uniquely qualify the lookup (nil if not required).
   130  func GetRedrivePolicy(ctx *pulumi.Context,
   131  	name string, id pulumi.IDInput, state *RedrivePolicyState, opts ...pulumi.ResourceOption) (*RedrivePolicy, error) {
   132  	var resource RedrivePolicy
   133  	err := ctx.ReadResource("aws:sqs/redrivePolicy:RedrivePolicy", name, id, state, &resource, opts...)
   134  	if err != nil {
   135  		return nil, err
   136  	}
   137  	return &resource, nil
   138  }
   139  
   140  // Input properties used for looking up and filtering RedrivePolicy resources.
   141  type redrivePolicyState struct {
   142  	// The URL of the SQS Queue to which to attach the policy
   143  	QueueUrl *string `pulumi:"queueUrl"`
   144  	// 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](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html).
   145  	RedrivePolicy *string `pulumi:"redrivePolicy"`
   146  }
   147  
   148  type RedrivePolicyState struct {
   149  	// The URL of the SQS Queue to which to attach the policy
   150  	QueueUrl pulumi.StringPtrInput
   151  	// 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](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html).
   152  	RedrivePolicy pulumi.StringPtrInput
   153  }
   154  
   155  func (RedrivePolicyState) ElementType() reflect.Type {
   156  	return reflect.TypeOf((*redrivePolicyState)(nil)).Elem()
   157  }
   158  
   159  type redrivePolicyArgs struct {
   160  	// The URL of the SQS Queue to which to attach the policy
   161  	QueueUrl string `pulumi:"queueUrl"`
   162  	// 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](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html).
   163  	RedrivePolicy string `pulumi:"redrivePolicy"`
   164  }
   165  
   166  // The set of arguments for constructing a RedrivePolicy resource.
   167  type RedrivePolicyArgs struct {
   168  	// The URL of the SQS Queue to which to attach the policy
   169  	QueueUrl pulumi.StringInput
   170  	// 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](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html).
   171  	RedrivePolicy pulumi.StringInput
   172  }
   173  
   174  func (RedrivePolicyArgs) ElementType() reflect.Type {
   175  	return reflect.TypeOf((*redrivePolicyArgs)(nil)).Elem()
   176  }
   177  
   178  type RedrivePolicyInput interface {
   179  	pulumi.Input
   180  
   181  	ToRedrivePolicyOutput() RedrivePolicyOutput
   182  	ToRedrivePolicyOutputWithContext(ctx context.Context) RedrivePolicyOutput
   183  }
   184  
   185  func (*RedrivePolicy) ElementType() reflect.Type {
   186  	return reflect.TypeOf((**RedrivePolicy)(nil)).Elem()
   187  }
   188  
   189  func (i *RedrivePolicy) ToRedrivePolicyOutput() RedrivePolicyOutput {
   190  	return i.ToRedrivePolicyOutputWithContext(context.Background())
   191  }
   192  
   193  func (i *RedrivePolicy) ToRedrivePolicyOutputWithContext(ctx context.Context) RedrivePolicyOutput {
   194  	return pulumi.ToOutputWithContext(ctx, i).(RedrivePolicyOutput)
   195  }
   196  
   197  // RedrivePolicyArrayInput is an input type that accepts RedrivePolicyArray and RedrivePolicyArrayOutput values.
   198  // You can construct a concrete instance of `RedrivePolicyArrayInput` via:
   199  //
   200  //	RedrivePolicyArray{ RedrivePolicyArgs{...} }
   201  type RedrivePolicyArrayInput interface {
   202  	pulumi.Input
   203  
   204  	ToRedrivePolicyArrayOutput() RedrivePolicyArrayOutput
   205  	ToRedrivePolicyArrayOutputWithContext(context.Context) RedrivePolicyArrayOutput
   206  }
   207  
   208  type RedrivePolicyArray []RedrivePolicyInput
   209  
   210  func (RedrivePolicyArray) ElementType() reflect.Type {
   211  	return reflect.TypeOf((*[]*RedrivePolicy)(nil)).Elem()
   212  }
   213  
   214  func (i RedrivePolicyArray) ToRedrivePolicyArrayOutput() RedrivePolicyArrayOutput {
   215  	return i.ToRedrivePolicyArrayOutputWithContext(context.Background())
   216  }
   217  
   218  func (i RedrivePolicyArray) ToRedrivePolicyArrayOutputWithContext(ctx context.Context) RedrivePolicyArrayOutput {
   219  	return pulumi.ToOutputWithContext(ctx, i).(RedrivePolicyArrayOutput)
   220  }
   221  
   222  // RedrivePolicyMapInput is an input type that accepts RedrivePolicyMap and RedrivePolicyMapOutput values.
   223  // You can construct a concrete instance of `RedrivePolicyMapInput` via:
   224  //
   225  //	RedrivePolicyMap{ "key": RedrivePolicyArgs{...} }
   226  type RedrivePolicyMapInput interface {
   227  	pulumi.Input
   228  
   229  	ToRedrivePolicyMapOutput() RedrivePolicyMapOutput
   230  	ToRedrivePolicyMapOutputWithContext(context.Context) RedrivePolicyMapOutput
   231  }
   232  
   233  type RedrivePolicyMap map[string]RedrivePolicyInput
   234  
   235  func (RedrivePolicyMap) ElementType() reflect.Type {
   236  	return reflect.TypeOf((*map[string]*RedrivePolicy)(nil)).Elem()
   237  }
   238  
   239  func (i RedrivePolicyMap) ToRedrivePolicyMapOutput() RedrivePolicyMapOutput {
   240  	return i.ToRedrivePolicyMapOutputWithContext(context.Background())
   241  }
   242  
   243  func (i RedrivePolicyMap) ToRedrivePolicyMapOutputWithContext(ctx context.Context) RedrivePolicyMapOutput {
   244  	return pulumi.ToOutputWithContext(ctx, i).(RedrivePolicyMapOutput)
   245  }
   246  
   247  type RedrivePolicyOutput struct{ *pulumi.OutputState }
   248  
   249  func (RedrivePolicyOutput) ElementType() reflect.Type {
   250  	return reflect.TypeOf((**RedrivePolicy)(nil)).Elem()
   251  }
   252  
   253  func (o RedrivePolicyOutput) ToRedrivePolicyOutput() RedrivePolicyOutput {
   254  	return o
   255  }
   256  
   257  func (o RedrivePolicyOutput) ToRedrivePolicyOutputWithContext(ctx context.Context) RedrivePolicyOutput {
   258  	return o
   259  }
   260  
   261  // The URL of the SQS Queue to which to attach the policy
   262  func (o RedrivePolicyOutput) QueueUrl() pulumi.StringOutput {
   263  	return o.ApplyT(func(v *RedrivePolicy) pulumi.StringOutput { return v.QueueUrl }).(pulumi.StringOutput)
   264  }
   265  
   266  // 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](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html).
   267  func (o RedrivePolicyOutput) RedrivePolicy() pulumi.StringOutput {
   268  	return o.ApplyT(func(v *RedrivePolicy) pulumi.StringOutput { return v.RedrivePolicy }).(pulumi.StringOutput)
   269  }
   270  
   271  type RedrivePolicyArrayOutput struct{ *pulumi.OutputState }
   272  
   273  func (RedrivePolicyArrayOutput) ElementType() reflect.Type {
   274  	return reflect.TypeOf((*[]*RedrivePolicy)(nil)).Elem()
   275  }
   276  
   277  func (o RedrivePolicyArrayOutput) ToRedrivePolicyArrayOutput() RedrivePolicyArrayOutput {
   278  	return o
   279  }
   280  
   281  func (o RedrivePolicyArrayOutput) ToRedrivePolicyArrayOutputWithContext(ctx context.Context) RedrivePolicyArrayOutput {
   282  	return o
   283  }
   284  
   285  func (o RedrivePolicyArrayOutput) Index(i pulumi.IntInput) RedrivePolicyOutput {
   286  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *RedrivePolicy {
   287  		return vs[0].([]*RedrivePolicy)[vs[1].(int)]
   288  	}).(RedrivePolicyOutput)
   289  }
   290  
   291  type RedrivePolicyMapOutput struct{ *pulumi.OutputState }
   292  
   293  func (RedrivePolicyMapOutput) ElementType() reflect.Type {
   294  	return reflect.TypeOf((*map[string]*RedrivePolicy)(nil)).Elem()
   295  }
   296  
   297  func (o RedrivePolicyMapOutput) ToRedrivePolicyMapOutput() RedrivePolicyMapOutput {
   298  	return o
   299  }
   300  
   301  func (o RedrivePolicyMapOutput) ToRedrivePolicyMapOutputWithContext(ctx context.Context) RedrivePolicyMapOutput {
   302  	return o
   303  }
   304  
   305  func (o RedrivePolicyMapOutput) MapIndex(k pulumi.StringInput) RedrivePolicyOutput {
   306  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *RedrivePolicy {
   307  		return vs[0].(map[string]*RedrivePolicy)[vs[1].(string)]
   308  	}).(RedrivePolicyOutput)
   309  }
   310  
   311  func init() {
   312  	pulumi.RegisterInputType(reflect.TypeOf((*RedrivePolicyInput)(nil)).Elem(), &RedrivePolicy{})
   313  	pulumi.RegisterInputType(reflect.TypeOf((*RedrivePolicyArrayInput)(nil)).Elem(), RedrivePolicyArray{})
   314  	pulumi.RegisterInputType(reflect.TypeOf((*RedrivePolicyMapInput)(nil)).Elem(), RedrivePolicyMap{})
   315  	pulumi.RegisterOutputType(RedrivePolicyOutput{})
   316  	pulumi.RegisterOutputType(RedrivePolicyArrayOutput{})
   317  	pulumi.RegisterOutputType(RedrivePolicyMapOutput{})
   318  }