# CfnRuleProps

Struct · External

Properties for defining a `CfnRule`.

Used as props by: [CfnRule](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rbin.CfnRule.html)

- Source: Generated at build time
- Type last changed: v2.169.0 · 21 Nov 2024

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_rbin as rbin } from 'aws-cdk-lib';
const cfnRuleProps: rbin.CfnRuleProps = {
  resourceType: 'resourceType',
  retentionPeriod: {
    retentionPeriodUnit: 'retentionPeriodUnit',
    retentionPeriodValue: 123,
  },

  // the properties below are optional
  description: 'description',
  excludeResourceTags: [{
    resourceTagKey: 'resourceTagKey',
    resourceTagValue: 'resourceTagValue',
  }],
  lockConfiguration: {
    unlockDelayUnit: 'unlockDelayUnit',
    unlockDelayValue: 123,
  },
  resourceTags: [{
    resourceTagKey: 'resourceTagKey',
    resourceTagValue: 'resourceTagValue',
  }],
  status: 'status',
  tags: [{
    key: 'key',
    value: 'value',
  }],
};
```

Python:

```python
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_rbin as rbin

cfn_rule_props = rbin.CfnRuleProps(
    resource_type="resourceType",
    retention_period=rbin.CfnRule.RetentionPeriodProperty(
        retention_period_unit="retentionPeriodUnit",
        retention_period_value=123
    ),

    # the properties below are optional
    description="description",
    exclude_resource_tags=[rbin.CfnRule.ResourceTagProperty(
        resource_tag_key="resourceTagKey",
        resource_tag_value="resourceTagValue"
    )],
    lock_configuration=rbin.CfnRule.UnlockDelayProperty(
        unlock_delay_unit="unlockDelayUnit",
        unlock_delay_value=123
    ),
    resource_tags=[rbin.CfnRule.ResourceTagProperty(
        resource_tag_key="resourceTagKey",
        resource_tag_value="resourceTagValue"
    )],
    status="status",
    tags=[CfnTag(
        key="key",
        value="value"
    )]
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.rbin.*;

CfnRuleProps cfnRuleProps = CfnRuleProps.builder()
        .resourceType("resourceType")
        .retentionPeriod(RetentionPeriodProperty.builder()
                .retentionPeriodUnit("retentionPeriodUnit")
                .retentionPeriodValue(123)
                .build())

        // the properties below are optional
        .description("description")
        .excludeResourceTags(List.of(ResourceTagProperty.builder()
                .resourceTagKey("resourceTagKey")
                .resourceTagValue("resourceTagValue")
                .build()))
        .lockConfiguration(UnlockDelayProperty.builder()
                .unlockDelayUnit("unlockDelayUnit")
                .unlockDelayValue(123)
                .build())
        .resourceTags(List.of(ResourceTagProperty.builder()
                .resourceTagKey("resourceTagKey")
                .resourceTagValue("resourceTagValue")
                .build()))
        .status("status")
        .tags(List.of(CfnTag.builder()
                .key("key")
                .value("value")
                .build()))
        .build();
```

C#:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Rbin;

var cfnRuleProps = new CfnRuleProps {
    ResourceType = "resourceType",
    RetentionPeriod = new RetentionPeriodProperty {
        RetentionPeriodUnit = "retentionPeriodUnit",
        RetentionPeriodValue = 123
    },

    // the properties below are optional
    Description = "description",
    ExcludeResourceTags = new [] { new ResourceTagProperty {
        ResourceTagKey = "resourceTagKey",
        ResourceTagValue = "resourceTagValue"
    } },
    LockConfiguration = new UnlockDelayProperty {
        UnlockDelayUnit = "unlockDelayUnit",
        UnlockDelayValue = 123
    },
    ResourceTags = new [] { new ResourceTagProperty {
        ResourceTagKey = "resourceTagKey",
        ResourceTagValue = "resourceTagValue"
    } },
    Status = "status",
    Tags = new [] { new CfnTag {
        Key = "key",
        Value = "value"
    } }
};
```

Go:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

cfnRuleProps := &CfnRuleProps{
	ResourceType: jsii.String("resourceType"),
	RetentionPeriod: &RetentionPeriodProperty{
		RetentionPeriodUnit: jsii.String("retentionPeriodUnit"),
		RetentionPeriodValue: jsii.Number(123),
	},

	// the properties below are optional
	Description: jsii.String("description"),
	ExcludeResourceTags: []interface{}{
		&ResourceTagProperty{
			ResourceTagKey: jsii.String("resourceTagKey"),
			ResourceTagValue: jsii.String("resourceTagValue"),
		},
	},
	LockConfiguration: &UnlockDelayProperty{
		UnlockDelayUnit: jsii.String("unlockDelayUnit"),
		UnlockDelayValue: jsii.Number(123),
	},
	ResourceTags: []interface{}{
		&ResourceTagProperty{
			ResourceTagKey: jsii.String("resourceTagKey"),
			ResourceTagValue: jsii.String("resourceTagValue"),
		},
	},
	Status: jsii.String("status"),
	Tags: []CfnTag{
		&CfnTag{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
}
```

## Properties

- `description`: string — The retention rule description.

- `excludeResourceTags`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnRule.ResourceTagProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rbin.CfnRule.ResourceTagProperty.html)[] — [Region-level retention rules only] Specifies the exclusion tags to use to identify resources that are to be excluded, or ignored, by a Region-level retention rule.

  Resources that have any of these tags are not retained by the retention rule upon deletion.

  You can't specify exclusion tags for tag-level retention rules.

- `lockConfiguration`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnRule.UnlockDelayProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rbin.CfnRule.UnlockDelayProperty.html) — Information about the retention rule lock configuration.

- `resourceTags`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnRule.ResourceTagProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rbin.CfnRule.ResourceTagProperty.html)[] — [Tag-level retention rules only] Specifies the resource tags to use to identify resources that are to be retained by a tag-level retention rule.

  For tag-level retention rules, only deleted resources, of the specified resource type, that have one or more of the specified tag key and value pairs are retained. If a resource is deleted, but it does not have any of the specified tag key and value pairs, it is immediately deleted without being retained by the retention rule.

  You can add the same tag key and value pair to a maximum or five retention rules.

  To create a Region-level retention rule, omit this parameter. A Region-level retention rule does not have any resource tags specified. It retains all deleted resources of the specified resource type in the Region in which the rule is created, even if the resources are not tagged.

- `resourceType`: string (required) — The resource type to be retained by the retention rule.

  Currently, only EBS volumes, EBS snapshots, and EBS-backed AMIs are supported.

  - To retain EBS volumes, specify `EBS_VOLUME` .
  - To retain EBS snapshots, specify `EBS_SNAPSHOT`
  - To retain EBS-backed AMIs, specify `EC2_IMAGE` .

- `retentionPeriod`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnRule.RetentionPeriodProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rbin.CfnRule.RetentionPeriodProperty.html) (required) — Information about the retention period for which the retention rule is to retain resources.

- `status`: string — The state of the retention rule.

  Only retention rules that are in the `available` state retain resources.

- `tags`: [CfnTag](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.CfnTag.html)[] — Information about the tags to assign to the retention rule.
