github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/rbin/rule.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 rbin
     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  // Resource for managing an AWS RBin Rule.
    16  //
    17  // ## Example Usage
    18  //
    19  // ### Basic Usage
    20  //
    21  // <!--Start PulumiCodeChooser -->
    22  // ```go
    23  // package main
    24  //
    25  // import (
    26  //
    27  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/rbin"
    28  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    29  //
    30  // )
    31  //
    32  //	func main() {
    33  //		pulumi.Run(func(ctx *pulumi.Context) error {
    34  //			_, err := rbin.NewRule(ctx, "example", &rbin.RuleArgs{
    35  //				Description:  pulumi.String("example_rule"),
    36  //				ResourceType: pulumi.String("EBS_SNAPSHOT"),
    37  //				ResourceTags: rbin.RuleResourceTagArray{
    38  //					&rbin.RuleResourceTagArgs{
    39  //						ResourceTagKey:   pulumi.String("tag_key"),
    40  //						ResourceTagValue: pulumi.String("tag_value"),
    41  //					},
    42  //				},
    43  //				RetentionPeriod: &rbin.RuleRetentionPeriodArgs{
    44  //					RetentionPeriodValue: pulumi.Int(10),
    45  //					RetentionPeriodUnit:  pulumi.String("DAYS"),
    46  //				},
    47  //				Tags: pulumi.StringMap{
    48  //					"test_tag_key": pulumi.String("test_tag_value"),
    49  //				},
    50  //			})
    51  //			if err != nil {
    52  //				return err
    53  //			}
    54  //			return nil
    55  //		})
    56  //	}
    57  //
    58  // ```
    59  // <!--End PulumiCodeChooser -->
    60  //
    61  // ## Import
    62  //
    63  // Using `pulumi import`, import RBin Rule using the `id`. For example:
    64  //
    65  // ```sh
    66  // $ pulumi import aws:rbin/rule:Rule example examplerule
    67  // ```
    68  type Rule struct {
    69  	pulumi.CustomResourceState
    70  
    71  	Arn pulumi.StringOutput `pulumi:"arn"`
    72  	// The retention rule description.
    73  	Description pulumi.StringOutput `pulumi:"description"`
    74  	// Information about the retention rule lock configuration. See `lockConfiguration` below.
    75  	LockConfiguration RuleLockConfigurationPtrOutput `pulumi:"lockConfiguration"`
    76  	// (Timestamp) The date and time at which the unlock delay is set to expire. Only returned for retention rules that have been unlocked and that are still within the unlock delay period.
    77  	LockEndTime pulumi.StringOutput `pulumi:"lockEndTime"`
    78  	// (Optional) The lock state of the retention rules to list. Only retention rules with the specified lock state are returned. Valid values are `locked`, `pendingUnlock`, `unlocked`.
    79  	LockState pulumi.StringOutput `pulumi:"lockState"`
    80  	// Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. See `resourceTags` below.
    81  	ResourceTags RuleResourceTagArrayOutput `pulumi:"resourceTags"`
    82  	// The resource type to be retained by the retention rule. Valid values are `EBS_SNAPSHOT` and `EC2_IMAGE`.
    83  	ResourceType pulumi.StringOutput `pulumi:"resourceType"`
    84  	// Information about the retention period for which the retention rule is to retain resources. See `retentionPeriod` below.
    85  	//
    86  	// The following arguments are optional:
    87  	RetentionPeriod RuleRetentionPeriodOutput `pulumi:"retentionPeriod"`
    88  	// (String) The state of the retention rule. Only retention rules that are in the `available` state retain resources. Valid values include `pending` and `available`.
    89  	Status pulumi.StringOutput    `pulumi:"status"`
    90  	Tags   pulumi.StringMapOutput `pulumi:"tags"`
    91  	// Deprecated: Please use `tags` instead.
    92  	TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
    93  }
    94  
    95  // NewRule registers a new resource with the given unique name, arguments, and options.
    96  func NewRule(ctx *pulumi.Context,
    97  	name string, args *RuleArgs, opts ...pulumi.ResourceOption) (*Rule, error) {
    98  	if args == nil {
    99  		return nil, errors.New("missing one or more required arguments")
   100  	}
   101  
   102  	if args.ResourceType == nil {
   103  		return nil, errors.New("invalid value for required argument 'ResourceType'")
   104  	}
   105  	if args.RetentionPeriod == nil {
   106  		return nil, errors.New("invalid value for required argument 'RetentionPeriod'")
   107  	}
   108  	opts = internal.PkgResourceDefaultOpts(opts)
   109  	var resource Rule
   110  	err := ctx.RegisterResource("aws:rbin/rule:Rule", name, args, &resource, opts...)
   111  	if err != nil {
   112  		return nil, err
   113  	}
   114  	return &resource, nil
   115  }
   116  
   117  // GetRule gets an existing Rule resource's state with the given name, ID, and optional
   118  // state properties that are used to uniquely qualify the lookup (nil if not required).
   119  func GetRule(ctx *pulumi.Context,
   120  	name string, id pulumi.IDInput, state *RuleState, opts ...pulumi.ResourceOption) (*Rule, error) {
   121  	var resource Rule
   122  	err := ctx.ReadResource("aws:rbin/rule:Rule", name, id, state, &resource, opts...)
   123  	if err != nil {
   124  		return nil, err
   125  	}
   126  	return &resource, nil
   127  }
   128  
   129  // Input properties used for looking up and filtering Rule resources.
   130  type ruleState struct {
   131  	Arn *string `pulumi:"arn"`
   132  	// The retention rule description.
   133  	Description *string `pulumi:"description"`
   134  	// Information about the retention rule lock configuration. See `lockConfiguration` below.
   135  	LockConfiguration *RuleLockConfiguration `pulumi:"lockConfiguration"`
   136  	// (Timestamp) The date and time at which the unlock delay is set to expire. Only returned for retention rules that have been unlocked and that are still within the unlock delay period.
   137  	LockEndTime *string `pulumi:"lockEndTime"`
   138  	// (Optional) The lock state of the retention rules to list. Only retention rules with the specified lock state are returned. Valid values are `locked`, `pendingUnlock`, `unlocked`.
   139  	LockState *string `pulumi:"lockState"`
   140  	// Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. See `resourceTags` below.
   141  	ResourceTags []RuleResourceTag `pulumi:"resourceTags"`
   142  	// The resource type to be retained by the retention rule. Valid values are `EBS_SNAPSHOT` and `EC2_IMAGE`.
   143  	ResourceType *string `pulumi:"resourceType"`
   144  	// Information about the retention period for which the retention rule is to retain resources. See `retentionPeriod` below.
   145  	//
   146  	// The following arguments are optional:
   147  	RetentionPeriod *RuleRetentionPeriod `pulumi:"retentionPeriod"`
   148  	// (String) The state of the retention rule. Only retention rules that are in the `available` state retain resources. Valid values include `pending` and `available`.
   149  	Status *string           `pulumi:"status"`
   150  	Tags   map[string]string `pulumi:"tags"`
   151  	// Deprecated: Please use `tags` instead.
   152  	TagsAll map[string]string `pulumi:"tagsAll"`
   153  }
   154  
   155  type RuleState struct {
   156  	Arn pulumi.StringPtrInput
   157  	// The retention rule description.
   158  	Description pulumi.StringPtrInput
   159  	// Information about the retention rule lock configuration. See `lockConfiguration` below.
   160  	LockConfiguration RuleLockConfigurationPtrInput
   161  	// (Timestamp) The date and time at which the unlock delay is set to expire. Only returned for retention rules that have been unlocked and that are still within the unlock delay period.
   162  	LockEndTime pulumi.StringPtrInput
   163  	// (Optional) The lock state of the retention rules to list. Only retention rules with the specified lock state are returned. Valid values are `locked`, `pendingUnlock`, `unlocked`.
   164  	LockState pulumi.StringPtrInput
   165  	// Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. See `resourceTags` below.
   166  	ResourceTags RuleResourceTagArrayInput
   167  	// The resource type to be retained by the retention rule. Valid values are `EBS_SNAPSHOT` and `EC2_IMAGE`.
   168  	ResourceType pulumi.StringPtrInput
   169  	// Information about the retention period for which the retention rule is to retain resources. See `retentionPeriod` below.
   170  	//
   171  	// The following arguments are optional:
   172  	RetentionPeriod RuleRetentionPeriodPtrInput
   173  	// (String) The state of the retention rule. Only retention rules that are in the `available` state retain resources. Valid values include `pending` and `available`.
   174  	Status pulumi.StringPtrInput
   175  	Tags   pulumi.StringMapInput
   176  	// Deprecated: Please use `tags` instead.
   177  	TagsAll pulumi.StringMapInput
   178  }
   179  
   180  func (RuleState) ElementType() reflect.Type {
   181  	return reflect.TypeOf((*ruleState)(nil)).Elem()
   182  }
   183  
   184  type ruleArgs struct {
   185  	// The retention rule description.
   186  	Description *string `pulumi:"description"`
   187  	// Information about the retention rule lock configuration. See `lockConfiguration` below.
   188  	LockConfiguration *RuleLockConfiguration `pulumi:"lockConfiguration"`
   189  	// Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. See `resourceTags` below.
   190  	ResourceTags []RuleResourceTag `pulumi:"resourceTags"`
   191  	// The resource type to be retained by the retention rule. Valid values are `EBS_SNAPSHOT` and `EC2_IMAGE`.
   192  	ResourceType string `pulumi:"resourceType"`
   193  	// Information about the retention period for which the retention rule is to retain resources. See `retentionPeriod` below.
   194  	//
   195  	// The following arguments are optional:
   196  	RetentionPeriod RuleRetentionPeriod `pulumi:"retentionPeriod"`
   197  	Tags            map[string]string   `pulumi:"tags"`
   198  }
   199  
   200  // The set of arguments for constructing a Rule resource.
   201  type RuleArgs struct {
   202  	// The retention rule description.
   203  	Description pulumi.StringPtrInput
   204  	// Information about the retention rule lock configuration. See `lockConfiguration` below.
   205  	LockConfiguration RuleLockConfigurationPtrInput
   206  	// Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. See `resourceTags` below.
   207  	ResourceTags RuleResourceTagArrayInput
   208  	// The resource type to be retained by the retention rule. Valid values are `EBS_SNAPSHOT` and `EC2_IMAGE`.
   209  	ResourceType pulumi.StringInput
   210  	// Information about the retention period for which the retention rule is to retain resources. See `retentionPeriod` below.
   211  	//
   212  	// The following arguments are optional:
   213  	RetentionPeriod RuleRetentionPeriodInput
   214  	Tags            pulumi.StringMapInput
   215  }
   216  
   217  func (RuleArgs) ElementType() reflect.Type {
   218  	return reflect.TypeOf((*ruleArgs)(nil)).Elem()
   219  }
   220  
   221  type RuleInput interface {
   222  	pulumi.Input
   223  
   224  	ToRuleOutput() RuleOutput
   225  	ToRuleOutputWithContext(ctx context.Context) RuleOutput
   226  }
   227  
   228  func (*Rule) ElementType() reflect.Type {
   229  	return reflect.TypeOf((**Rule)(nil)).Elem()
   230  }
   231  
   232  func (i *Rule) ToRuleOutput() RuleOutput {
   233  	return i.ToRuleOutputWithContext(context.Background())
   234  }
   235  
   236  func (i *Rule) ToRuleOutputWithContext(ctx context.Context) RuleOutput {
   237  	return pulumi.ToOutputWithContext(ctx, i).(RuleOutput)
   238  }
   239  
   240  // RuleArrayInput is an input type that accepts RuleArray and RuleArrayOutput values.
   241  // You can construct a concrete instance of `RuleArrayInput` via:
   242  //
   243  //	RuleArray{ RuleArgs{...} }
   244  type RuleArrayInput interface {
   245  	pulumi.Input
   246  
   247  	ToRuleArrayOutput() RuleArrayOutput
   248  	ToRuleArrayOutputWithContext(context.Context) RuleArrayOutput
   249  }
   250  
   251  type RuleArray []RuleInput
   252  
   253  func (RuleArray) ElementType() reflect.Type {
   254  	return reflect.TypeOf((*[]*Rule)(nil)).Elem()
   255  }
   256  
   257  func (i RuleArray) ToRuleArrayOutput() RuleArrayOutput {
   258  	return i.ToRuleArrayOutputWithContext(context.Background())
   259  }
   260  
   261  func (i RuleArray) ToRuleArrayOutputWithContext(ctx context.Context) RuleArrayOutput {
   262  	return pulumi.ToOutputWithContext(ctx, i).(RuleArrayOutput)
   263  }
   264  
   265  // RuleMapInput is an input type that accepts RuleMap and RuleMapOutput values.
   266  // You can construct a concrete instance of `RuleMapInput` via:
   267  //
   268  //	RuleMap{ "key": RuleArgs{...} }
   269  type RuleMapInput interface {
   270  	pulumi.Input
   271  
   272  	ToRuleMapOutput() RuleMapOutput
   273  	ToRuleMapOutputWithContext(context.Context) RuleMapOutput
   274  }
   275  
   276  type RuleMap map[string]RuleInput
   277  
   278  func (RuleMap) ElementType() reflect.Type {
   279  	return reflect.TypeOf((*map[string]*Rule)(nil)).Elem()
   280  }
   281  
   282  func (i RuleMap) ToRuleMapOutput() RuleMapOutput {
   283  	return i.ToRuleMapOutputWithContext(context.Background())
   284  }
   285  
   286  func (i RuleMap) ToRuleMapOutputWithContext(ctx context.Context) RuleMapOutput {
   287  	return pulumi.ToOutputWithContext(ctx, i).(RuleMapOutput)
   288  }
   289  
   290  type RuleOutput struct{ *pulumi.OutputState }
   291  
   292  func (RuleOutput) ElementType() reflect.Type {
   293  	return reflect.TypeOf((**Rule)(nil)).Elem()
   294  }
   295  
   296  func (o RuleOutput) ToRuleOutput() RuleOutput {
   297  	return o
   298  }
   299  
   300  func (o RuleOutput) ToRuleOutputWithContext(ctx context.Context) RuleOutput {
   301  	return o
   302  }
   303  
   304  func (o RuleOutput) Arn() pulumi.StringOutput {
   305  	return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
   306  }
   307  
   308  // The retention rule description.
   309  func (o RuleOutput) Description() pulumi.StringOutput {
   310  	return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.Description }).(pulumi.StringOutput)
   311  }
   312  
   313  // Information about the retention rule lock configuration. See `lockConfiguration` below.
   314  func (o RuleOutput) LockConfiguration() RuleLockConfigurationPtrOutput {
   315  	return o.ApplyT(func(v *Rule) RuleLockConfigurationPtrOutput { return v.LockConfiguration }).(RuleLockConfigurationPtrOutput)
   316  }
   317  
   318  // (Timestamp) The date and time at which the unlock delay is set to expire. Only returned for retention rules that have been unlocked and that are still within the unlock delay period.
   319  func (o RuleOutput) LockEndTime() pulumi.StringOutput {
   320  	return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.LockEndTime }).(pulumi.StringOutput)
   321  }
   322  
   323  // (Optional) The lock state of the retention rules to list. Only retention rules with the specified lock state are returned. Valid values are `locked`, `pendingUnlock`, `unlocked`.
   324  func (o RuleOutput) LockState() pulumi.StringOutput {
   325  	return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.LockState }).(pulumi.StringOutput)
   326  }
   327  
   328  // Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. See `resourceTags` below.
   329  func (o RuleOutput) ResourceTags() RuleResourceTagArrayOutput {
   330  	return o.ApplyT(func(v *Rule) RuleResourceTagArrayOutput { return v.ResourceTags }).(RuleResourceTagArrayOutput)
   331  }
   332  
   333  // The resource type to be retained by the retention rule. Valid values are `EBS_SNAPSHOT` and `EC2_IMAGE`.
   334  func (o RuleOutput) ResourceType() pulumi.StringOutput {
   335  	return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.ResourceType }).(pulumi.StringOutput)
   336  }
   337  
   338  // Information about the retention period for which the retention rule is to retain resources. See `retentionPeriod` below.
   339  //
   340  // The following arguments are optional:
   341  func (o RuleOutput) RetentionPeriod() RuleRetentionPeriodOutput {
   342  	return o.ApplyT(func(v *Rule) RuleRetentionPeriodOutput { return v.RetentionPeriod }).(RuleRetentionPeriodOutput)
   343  }
   344  
   345  // (String) The state of the retention rule. Only retention rules that are in the `available` state retain resources. Valid values include `pending` and `available`.
   346  func (o RuleOutput) Status() pulumi.StringOutput {
   347  	return o.ApplyT(func(v *Rule) pulumi.StringOutput { return v.Status }).(pulumi.StringOutput)
   348  }
   349  
   350  func (o RuleOutput) Tags() pulumi.StringMapOutput {
   351  	return o.ApplyT(func(v *Rule) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
   352  }
   353  
   354  // Deprecated: Please use `tags` instead.
   355  func (o RuleOutput) TagsAll() pulumi.StringMapOutput {
   356  	return o.ApplyT(func(v *Rule) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
   357  }
   358  
   359  type RuleArrayOutput struct{ *pulumi.OutputState }
   360  
   361  func (RuleArrayOutput) ElementType() reflect.Type {
   362  	return reflect.TypeOf((*[]*Rule)(nil)).Elem()
   363  }
   364  
   365  func (o RuleArrayOutput) ToRuleArrayOutput() RuleArrayOutput {
   366  	return o
   367  }
   368  
   369  func (o RuleArrayOutput) ToRuleArrayOutputWithContext(ctx context.Context) RuleArrayOutput {
   370  	return o
   371  }
   372  
   373  func (o RuleArrayOutput) Index(i pulumi.IntInput) RuleOutput {
   374  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *Rule {
   375  		return vs[0].([]*Rule)[vs[1].(int)]
   376  	}).(RuleOutput)
   377  }
   378  
   379  type RuleMapOutput struct{ *pulumi.OutputState }
   380  
   381  func (RuleMapOutput) ElementType() reflect.Type {
   382  	return reflect.TypeOf((*map[string]*Rule)(nil)).Elem()
   383  }
   384  
   385  func (o RuleMapOutput) ToRuleMapOutput() RuleMapOutput {
   386  	return o
   387  }
   388  
   389  func (o RuleMapOutput) ToRuleMapOutputWithContext(ctx context.Context) RuleMapOutput {
   390  	return o
   391  }
   392  
   393  func (o RuleMapOutput) MapIndex(k pulumi.StringInput) RuleOutput {
   394  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *Rule {
   395  		return vs[0].(map[string]*Rule)[vs[1].(string)]
   396  	}).(RuleOutput)
   397  }
   398  
   399  func init() {
   400  	pulumi.RegisterInputType(reflect.TypeOf((*RuleInput)(nil)).Elem(), &Rule{})
   401  	pulumi.RegisterInputType(reflect.TypeOf((*RuleArrayInput)(nil)).Elem(), RuleArray{})
   402  	pulumi.RegisterInputType(reflect.TypeOf((*RuleMapInput)(nil)).Elem(), RuleMap{})
   403  	pulumi.RegisterOutputType(RuleOutput{})
   404  	pulumi.RegisterOutputType(RuleArrayOutput{})
   405  	pulumi.RegisterOutputType(RuleMapOutput{})
   406  }