Skip to content
v2.278.0

LifecycleConfigurationProperty Struct ​

Specifies the lifecycle configuration for objects in an Amazon S3 bucket.

For more information, see Object Lifecycle Management in the Amazon S3 User Guide .

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 lifecycleConfigurationProperty: s3.CfnBucket.LifecycleConfigurationProperty = {
  rules: [{
    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,
    }],
  }],

  // the properties below are optional
  transitionDefaultMinimumObjectSize: 'transitionDefaultMinimumObjectSize',
};
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

lifecycle_configuration_property = s3.CfnBucket.LifecycleConfigurationProperty(
    rules=[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
        )]
    )],

    # the properties below are optional
    transition_default_minimum_object_size="transitionDefaultMinimumObjectSize"
)
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.*;

LifecycleConfigurationProperty lifecycleConfigurationProperty = LifecycleConfigurationProperty.builder()
        .rules(List.of(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()))

        // the properties below are optional
        .transitionDefaultMinimumObjectSize("transitionDefaultMinimumObjectSize")
        .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 lifecycleConfigurationProperty = new LifecycleConfigurationProperty {
    Rules = new [] { 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
        } }
    } },

    // the properties below are optional
    TransitionDefaultMinimumObjectSize = "transitionDefaultMinimumObjectSize"
};
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"

lifecycleConfigurationProperty := &LifecycleConfigurationProperty{
	Rules: []interface{}{
		&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),
				},
			},
		},
	},

	// the properties below are optional
	TransitionDefaultMinimumObjectSize: jsii.String("transitionDefaultMinimumObjectSize"),
}

Properties ​

rulesIResolvable | IResolvable | CfnBucket.RuleProperty[]rulestyping.Union[IResolvable, typing.List[typing.Union[IResolvable, RuleProperty]]]rulesIResolvableRulesIResolvableRulesinterface{} required #
A lifecycle rule for individual objects in an Amazon S3 bucket.
transitionDefaultMinimumObjectSizeoptionalstringtransition_default_minimum_object_sizeoptionalstrtransitionDefaultMinimumObjectSizeoptionalStringTransitionDefaultMinimumObjectSizeoptionalstringTransitionDefaultMinimumObjectSizeoptional*string #
Indicates which default minimum object size behavior is applied to the lifecycle configuration.
notes

This parameter applies to general purpose buckets only. It isn't supported for directory bucket lifecycle configurations.

  • all_storage_classes_128K - Objects smaller than 128 KB will not transition to any storage class by default.
  • varies_by_storage_class - Objects smaller than 128 KB will transition to Glacier Flexible Retrieval or Glacier Deep Archive storage classes. By default, all other storage classes will prevent transitions smaller than 128 KB.

To customize the minimum object size for any transition you can add a filter that specifies a custom ObjectSizeGreaterThan or ObjectSizeLessThan in the body of your transition rule. Custom filters always take precedence over the default transition behavior.