Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add excludeResourceTags for aws_rbin_rule #40937

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/40937.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resouce/aws_rbin_rule: Add `exclude_resource_tags` argument
```
42 changes: 41 additions & 1 deletion internal/service/rbin/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,32 @@ func ResourceRule() *schema.Resource {
names.AttrResourceTags: {
Type: schema.TypeSet,
Optional: true,
Computed: true,
MaxItems: 50,
ConflictsWith: []string{
"exclude_resource_tags",
},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"resource_tag_key": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringLenBetween(0, 127),
},
"resource_tag_value": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(0, 256),
},
},
},
},
"exclude_resource_tags": {
Type: schema.TypeSet,
Optional: true,
MaxItems: 5,
ConflictsWith: []string{
names.AttrResourceTags,
},
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"resource_tag_key": {
Expand Down Expand Up @@ -175,6 +199,9 @@ func resourceRuleCreate(ctx context.Context, d *schema.ResourceData, meta interf
if v, ok := d.GetOk(names.AttrResourceTags); ok && v.(*schema.Set).Len() > 0 {
in.ResourceTags = expandResourceTags(v.(*schema.Set).List())
}
if v, ok := d.GetOk("exclude_resource_tags"); ok && v.(*schema.Set).Len() > 0 {
in.ExcludeResourceTags = expandResourceTags(v.(*schema.Set).List())
}

out, err := conn.CreateRule(ctx, in)
if err != nil {
Expand Down Expand Up @@ -226,6 +253,9 @@ func resourceRuleRead(ctx context.Context, d *schema.ResourceData, meta interfac
if err := d.Set(names.AttrResourceTags, flattenResourceTags(out.ResourceTags)); err != nil {
return create.AppendDiagError(diags, names.RBin, create.ErrActionSetting, ResNameRule, d.Id(), err)
}
if err := d.Set("exclude_resource_tags", flattenResourceTags(out.ExcludeResourceTags)); err != nil {
return create.AppendDiagError(diags, names.RBin, create.ErrActionSetting, ResNameRule, d.Id(), err)
}

if err := d.Set(names.AttrRetentionPeriod, flattenRetentionPeriod(out.RetentionPeriod)); err != nil {
return create.AppendDiagError(diags, names.RBin, create.ErrActionSetting, ResNameRule, d.Id(), err)
Expand All @@ -251,6 +281,16 @@ func resourceRuleUpdate(ctx context.Context, d *schema.ResourceData, meta interf

if d.HasChanges(names.AttrResourceTags) {
in.ResourceTags = expandResourceTags(d.Get(names.AttrResourceTags).(*schema.Set).List())
if in.ResourceTags == nil {
in.ResourceTags = []types.ResourceTag{}
}
update = true
}
if d.HasChanges("exclude_resource_tags") {
in.ExcludeResourceTags = expandResourceTags(d.Get("exclude_resource_tags").(*schema.Set).List())
if in.ExcludeResourceTags == nil {
in.ExcludeResourceTags = []types.ResourceTag{}
}
update = true
}

Expand Down
11 changes: 11 additions & 0 deletions website/docs/r/rbin_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The following arguments are required:
The following arguments are optional:

* `description` - (Optional) The retention rule description.
* `exclude_resource_tags` - (Optional) Specifies the exclusion tags to use to identify resources that are to be excluded, or ignored, by a Region-level retention rule. See [`exclude_resource_tags`](#exclude_resource_tags) below.
* `resource_tags` - (Optional) Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule. See [`resource_tags`](#resource_tags) below.
* `lock_configuration` - (Optional) Information about the retention rule lock configuration. See [`lock_configuration`](#lock_configuration) below.

Expand All @@ -55,6 +56,16 @@ The following arguments are required:
* `retention_period_unit` - (Required) The unit of time in which the retention period is measured. Currently, only DAYS is supported.
* `retention_period_value` - (Required) The period value for which the retention rule is to retain resources. The period is measured using the unit specified for RetentionPeriodUnit.

### exclude_resource_tags

The following argument is required:

* `resource_tag_key` - (Required) The tag key.

The following argument is optional:

* `resource_tag_value` - (Optional) The tag value.

### resource_tags

The following argument is required:
Expand Down
Loading