Skip to content
v2.278.0

RuleProperty Struct ​

Specifies lifecycle rules for an Amazon S3 bucket.

For more information, see Put Bucket Lifecycle Configuration in the Amazon S3 API Reference .

You must specify at least one of the following properties: AbortIncompleteMultipartUpload , ExpirationDate , ExpirationInDays , NoncurrentVersionExpirationInDays , NoncurrentVersionTransition , NoncurrentVersionTransitions , Transition , or Transitions .

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_s3 as s3 } from 'aws-cdk-lib';
const ruleProperty: s3.CfnBucket.RuleProperty = {
  status: 'status',

  // the properties below are optional
  abortIncompleteMultipartUpload: {
    daysAfterInitiation: 123,
  },
  expirationDate: new Date(),
  expirationInDays: 123,
  expiredObjectDeleteMarker: false,
  id: 'id',
  noncurrentVersionExpiration: {
    noncurrentDays: 123,

    // the properties below are optional
    newerNoncurrentVersions: 123,
  },
  noncurrentVersionExpirationInDays: 123,
  noncurrentVersionTransition: {
    storageClass: 'storageClass',
    transitionInDays: 123,

    // the properties below are optional
    newerNoncurrentVersions: 123,
  },
  noncurrentVersionTransitions: [{
    storageClass: 'storageClass',
    transitionInDays: 123,

    // the properties below are optional
    newerNoncurrentVersions: 123,
  }],
  objectSizeGreaterThan: 123,
  objectSizeLessThan: 123,
  prefix: 'prefix',
  tagFilters: [{
    key: 'key',
    value: 'value',
  }],
  transition: {
    storageClass: 'storageClass',

    // the properties below are optional
    transitionDate: new Date(),
    transitionInDays: 123,
  },
  transitions: [{
    storageClass: 'storageClass',

    // the properties below are optional
    transitionDate: new Date(),
    transitionInDays: 123,
  }],
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_s3 as s3

rule_property = s3.CfnBucket.RuleProperty(
    status="status",

    # the properties below are optional
    abort_incomplete_multipart_upload=s3.CfnBucket.AbortIncompleteMultipartUploadProperty(
        days_after_initiation=123
    ),
    expiration_date=Date(),
    expiration_in_days=123,
    expired_object_delete_marker=False,
    id="id",
    noncurrent_version_expiration=s3.CfnBucket.NoncurrentVersionExpirationProperty(
        noncurrent_days=123,

        # the properties below are optional
        newer_noncurrent_versions=123
    ),
    noncurrent_version_expiration_in_days=123,
    noncurrent_version_transition=s3.CfnBucket.NoncurrentVersionTransitionProperty(
        storage_class="storageClass",
        transition_in_days=123,

        # the properties below are optional
        newer_noncurrent_versions=123
    ),
    noncurrent_version_transitions=[s3.CfnBucket.NoncurrentVersionTransitionProperty(
        storage_class="storageClass",
        transition_in_days=123,

        # the properties below are optional
        newer_noncurrent_versions=123
    )],
    object_size_greater_than=123,
    object_size_less_than=123,
    prefix="prefix",
    tag_filters=[s3.CfnBucket.TagFilterProperty(
        key="key",
        value="value"
    )],
    transition=s3.CfnBucket.TransitionProperty(
        storage_class="storageClass",

        # the properties below are optional
        transition_date=Date(),
        transition_in_days=123
    ),
    transitions=[s3.CfnBucket.TransitionProperty(
        storage_class="storageClass",

        # the properties below are optional
        transition_date=Date(),
        transition_in_days=123
    )]
)
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.s3.*;

RuleProperty ruleProperty = RuleProperty.builder()
        .status("status")

        // the properties below are optional
        .abortIncompleteMultipartUpload(AbortIncompleteMultipartUploadProperty.builder()
                .daysAfterInitiation(123)
                .build())
        .expirationDate(new Date())
        .expirationInDays(123)
        .expiredObjectDeleteMarker(false)
        .id("id")
        .noncurrentVersionExpiration(NoncurrentVersionExpirationProperty.builder()
                .noncurrentDays(123)

                // the properties below are optional
                .newerNoncurrentVersions(123)
                .build())
        .noncurrentVersionExpirationInDays(123)
        .noncurrentVersionTransition(NoncurrentVersionTransitionProperty.builder()
                .storageClass("storageClass")
                .transitionInDays(123)

                // the properties below are optional
                .newerNoncurrentVersions(123)
                .build())
        .noncurrentVersionTransitions(List.of(NoncurrentVersionTransitionProperty.builder()
                .storageClass("storageClass")
                .transitionInDays(123)

                // the properties below are optional
                .newerNoncurrentVersions(123)
                .build()))
        .objectSizeGreaterThan(123)
        .objectSizeLessThan(123)
        .prefix("prefix")
        .tagFilters(List.of(TagFilterProperty.builder()
                .key("key")
                .value("value")
                .build()))
        .transition(TransitionProperty.builder()
                .storageClass("storageClass")

                // the properties below are optional
                .transitionDate(new Date())
                .transitionInDays(123)
                .build())
        .transitions(List.of(TransitionProperty.builder()
                .storageClass("storageClass")

                // the properties below are optional
                .transitionDate(new Date())
                .transitionInDays(123)
                .build()))
        .build();
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.S3;

var ruleProperty = new RuleProperty {
    Status = "status",

    // the properties below are optional
    AbortIncompleteMultipartUpload = new AbortIncompleteMultipartUploadProperty {
        DaysAfterInitiation = 123
    },
    ExpirationDate = new Date(),
    ExpirationInDays = 123,
    ExpiredObjectDeleteMarker = false,
    Id = "id",
    NoncurrentVersionExpiration = new NoncurrentVersionExpirationProperty {
        NoncurrentDays = 123,

        // the properties below are optional
        NewerNoncurrentVersions = 123
    },
    NoncurrentVersionExpirationInDays = 123,
    NoncurrentVersionTransition = new NoncurrentVersionTransitionProperty {
        StorageClass = "storageClass",
        TransitionInDays = 123,

        // the properties below are optional
        NewerNoncurrentVersions = 123
    },
    NoncurrentVersionTransitions = new [] { new NoncurrentVersionTransitionProperty {
        StorageClass = "storageClass",
        TransitionInDays = 123,

        // the properties below are optional
        NewerNoncurrentVersions = 123
    } },
    ObjectSizeGreaterThan = 123,
    ObjectSizeLessThan = 123,
    Prefix = "prefix",
    TagFilters = new [] { new TagFilterProperty {
        Key = "key",
        Value = "value"
    } },
    Transition = new TransitionProperty {
        StorageClass = "storageClass",

        // the properties below are optional
        TransitionDate = new Date(),
        TransitionInDays = 123
    },
    Transitions = new [] { new TransitionProperty {
        StorageClass = "storageClass",

        // the properties below are optional
        TransitionDate = new Date(),
        TransitionInDays = 123
    } }
};
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"

ruleProperty := &RuleProperty{
	Status: jsii.String("status"),

	// the properties below are optional
	AbortIncompleteMultipartUpload: &AbortIncompleteMultipartUploadProperty{
		DaysAfterInitiation: jsii.Number(123),
	},
	ExpirationDate: NewDate(),
	ExpirationInDays: jsii.Number(123),
	ExpiredObjectDeleteMarker: jsii.Boolean(false),
	Id: jsii.String("id"),
	NoncurrentVersionExpiration: &NoncurrentVersionExpirationProperty{
		NoncurrentDays: jsii.Number(123),

		// the properties below are optional
		NewerNoncurrentVersions: jsii.Number(123),
	},
	NoncurrentVersionExpirationInDays: jsii.Number(123),
	NoncurrentVersionTransition: &NoncurrentVersionTransitionProperty{
		StorageClass: jsii.String("storageClass"),
		TransitionInDays: jsii.Number(123),

		// the properties below are optional
		NewerNoncurrentVersions: jsii.Number(123),
	},
	NoncurrentVersionTransitions: []interface{}{
		&NoncurrentVersionTransitionProperty{
			StorageClass: jsii.String("storageClass"),
			TransitionInDays: jsii.Number(123),

			// the properties below are optional
			NewerNoncurrentVersions: jsii.Number(123),
		},
	},
	ObjectSizeGreaterThan: jsii.Number(123),
	ObjectSizeLessThan: jsii.Number(123),
	Prefix: jsii.String("prefix"),
	TagFilters: []interface{}{
		&TagFilterProperty{
			Key: jsii.String("key"),
			Value: jsii.String("value"),
		},
	},
	Transition: &TransitionProperty{
		StorageClass: jsii.String("storageClass"),

		// the properties below are optional
		TransitionDate: NewDate(),
		TransitionInDays: jsii.Number(123),
	},
	Transitions: []interface{}{
		&TransitionProperty{
			StorageClass: jsii.String("storageClass"),

			// the properties below are optional
			TransitionDate: NewDate(),
			TransitionInDays: jsii.Number(123),
		},
	},
}

Properties ​

abortIncompleteMultipartUploadoptionalIResolvable | CfnBucket.AbortIncompleteMultipartUploadPropertyabort_incomplete_multipart_uploadoptionaltyping.Union[IResolvable, AbortIncompleteMultipartUploadProperty]abortIncompleteMultipartUploadoptionalIResolvableAbortIncompleteMultipartUploadoptionalIResolvableAbortIncompleteMultipartUploadoptionalinterface{} #
Specifies a lifecycle rule that stops incomplete multipart uploads to an Amazon S3 bucket.
expirationDateoptionaldate | IResolvableexpiration_dateoptionaltyping.Union[datetime, IResolvable]expirationDateoptionalInstantExpirationDateoptionalDateTimeExpirationDateoptionalinterface{} #
Indicates when objects are deleted from Amazon S3 and Amazon S3 Glacier.
notes

The date value must be in ISO 8601 format. The time is always midnight UTC. If you specify an expiration and transition time, you must use the same time unit for both properties (either in days or by date). The expiration time must also be later than the transition time.

expirationInDaysoptionalnumberexpiration_in_daysoptionalint | floatexpirationInDaysoptionalNumberExpirationInDaysoptionaldoubleExpirationInDaysoptional*float64 #
Indicates the number of days after creation when objects are deleted from Amazon S3 and Amazon S3 Glacier.

If you specify an expiration and transition time, you must use the same time unit for both properties (either in days or by date). The expiration time must also be later than the transition time.

expiredObjectDeleteMarkeroptionalboolean | IResolvableexpired_object_delete_markeroptionaltyping.Union[bool, IResolvable]expiredObjectDeleteMarkeroptionalBooleanExpiredObjectDeleteMarkeroptionalboolExpiredObjectDeleteMarkeroptionalinterface{} #
Indicates whether Amazon S3 will remove a delete marker without any noncurrent versions.

If set to true, the delete marker will be removed if there are no noncurrent versions. This cannot be specified with ExpirationInDays , ExpirationDate , or TagFilters .

idoptionalstringidoptionalstridoptionalStringIdoptionalstringIdoptional*string #
Unique identifier for the rule.

The value can't be longer than 255 characters.

noncurrentVersionExpirationoptionalIResolvable | CfnBucket.NoncurrentVersionExpirationPropertynoncurrent_version_expirationoptionaltyping.Union[IResolvable, NoncurrentVersionExpirationProperty]noncurrentVersionExpirationoptionalIResolvableNoncurrentVersionExpirationoptionalIResolvableNoncurrentVersionExpirationoptionalinterface{} #
Specifies when noncurrent object versions expire.
notes

Upon expiration, Amazon S3 permanently deletes the noncurrent object versions. You set this lifecycle configuration action on a bucket that has versioning enabled (or suspended) to request that Amazon S3 delete noncurrent object versions at a specific period in the object's lifetime.

noncurrentVersionExpirationInDaysoptionalnumbernoncurrent_version_expiration_in_daysoptionalint | floatnoncurrentVersionExpirationInDaysoptionalNumberNoncurrentVersionExpirationInDaysoptionaldoubleNoncurrentVersionExpirationInDaysoptional*float64 #
(Deprecated.) For buckets with versioning enabled (or suspended), specifies the time, in days, between when a new version of the object is uploaded to the bucket and when old versions of the object expire. When object versions expire, Amazon S3 permanently deletes them. If you specify a transition and expiration time, the expiration time must be later than the transition time.
noncurrentVersionTransitionoptionalIResolvable | CfnBucket.NoncurrentVersionTransitionPropertynoncurrent_version_transitionoptionaltyping.Union[IResolvable, NoncurrentVersionTransitionProperty]noncurrentVersionTransitionoptionalIResolvableNoncurrentVersionTransitionoptionalIResolvableNoncurrentVersionTransitionoptionalinterface{} #
(Deprecated.) For buckets with versioning enabled (or suspended), specifies when non-current objects transition to a specified storage class. If you specify a transition and expiration time, the expiration time must be later than the transition time. If you specify this property, don't specify the `NoncurrentVersionTransitions` property.
noncurrentVersionTransitionsoptionalIResolvable | IResolvable | CfnBucket.NoncurrentVersionTransitionProperty[]noncurrent_version_transitionsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, NoncurrentVersionTransitionProperty]]]noncurrentVersionTransitionsoptionalIResolvableNoncurrentVersionTransitionsoptionalIResolvableNoncurrentVersionTransitionsoptionalinterface{} #
For buckets with versioning enabled (or suspended), one or more transition rules that specify when non-current objects transition to a specified storage class.

If you specify a transition and expiration time, the expiration time must be later than the transition time. If you specify this property, don't specify the NoncurrentVersionTransition property.

objectSizeGreaterThanoptionalnumberobject_size_greater_thanoptionalint | floatobjectSizeGreaterThanoptionalNumberObjectSizeGreaterThanoptionaldoubleObjectSizeGreaterThanoptional*float64 #
Specifies the minimum object size in bytes for this rule to apply to.
notes

Objects must be larger than this value in bytes. For more information about size based rules, see Lifecycle configuration using size-based rules in the Amazon S3 User Guide .

objectSizeLessThanoptionalnumberobject_size_less_thanoptionalint | floatobjectSizeLessThanoptionalNumberObjectSizeLessThanoptionaldoubleObjectSizeLessThanoptional*float64 #
Specifies the maximum object size in bytes for this rule to apply to.
notes

Objects must be smaller than this value in bytes. For more information about sized based rules, see Lifecycle configuration using size-based rules in the Amazon S3 User Guide .

prefixoptionalstringprefixoptionalstrprefixoptionalStringPrefixoptionalstringPrefixoptional*string #
Object key prefix that identifies one or more objects to which this rule applies.
notes

Replacement must be made for object keys containing special characters (such as carriage returns) when using XML requests. For more information, see XML related object key constraints .

statusstringstatusstrstatusStringStatusstringStatus*string required #
If `Enabled` , the rule is currently being applied.

If Disabled , the rule is not currently being applied.

tagFiltersoptionalIResolvable | IResolvable | CfnBucket.TagFilterProperty[]tag_filtersoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, TagFilterProperty]]]tagFiltersoptionalIResolvableTagFiltersoptionalIResolvableTagFiltersoptionalinterface{} #
Tags to use to identify a subset of objects to which the lifecycle rule applies.
transitionoptionalIResolvable | CfnBucket.TransitionPropertytransitionoptionaltyping.Union[IResolvable, TransitionProperty]transitionoptionalIResolvableTransitionoptionalIResolvableTransitionoptionalinterface{} #
(Deprecated.) Specifies when an object transitions to a specified storage class. If you specify an expiration and transition time, you must use the same time unit for both properties (either in days or by date). The expiration time must also be later than the transition time. If you specify this property, don't specify the `Transitions` property.
transitionsoptionalIResolvable | IResolvable | CfnBucket.TransitionProperty[]transitionsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, TransitionProperty]]]transitionsoptionalIResolvableTransitionsoptionalIResolvableTransitionsoptionalinterface{} #
One or more transition rules that specify when an object transitions to a specified storage class.
notes

If you specify an expiration and transition time, you must use the same time unit for both properties (either in days or by date). The expiration time must also be later than the transition time. If you specify this property, don't specify the Transition property.