Skip to content
v2.275.0

LifecycleRule Struct ​

Declaration of a Life cycle rule.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_s3 as s3 } from 'aws-cdk-lib';

declare const storageClass: s3.StorageClass;
declare const tagFilters: any;
const lifecycleRule: s3.LifecycleRule = {
  abortIncompleteMultipartUploadAfter: cdk.Duration.minutes(30),
  enabled: false,
  expiration: cdk.Duration.minutes(30),
  expirationDate: new Date(),
  expiredObjectDeleteMarker: false,
  id: 'id',
  noncurrentVersionExpiration: cdk.Duration.minutes(30),
  noncurrentVersionsToRetain: 123,
  noncurrentVersionTransitions: [{
    storageClass: storageClass,
    transitionAfter: cdk.Duration.minutes(30),

    // the properties below are optional
    noncurrentVersionsToRetain: 123,
  }],
  objectSizeGreaterThan: 123,
  objectSizeLessThan: 123,
  prefix: 'prefix',
  tagFilters: {
    tagFiltersKey: tagFilters,
  },
  transitions: [{
    storageClass: storageClass,

    // the properties below are optional
    transitionAfter: cdk.Duration.minutes(30),
    transitionDate: new Date(),
  }],
};

Properties ​

abortIncompleteMultipartUploadAfteroptionalDurationabort_incomplete_multipart_upload_afteroptionalDurationabortIncompleteMultipartUploadAfteroptionalDurationAbortIncompleteMultipartUploadAfteroptionalDurationAbortIncompleteMultipartUploadAfteroptionalDuration#
Specifies a lifecycle rule that aborts incomplete multipart uploads to an Amazon S3 bucket.

Default: Incomplete uploads are never aborted

notes

The AbortIncompleteMultipartUpload property type creates a lifecycle rule that aborts incomplete multipart uploads to an Amazon S3 bucket. When Amazon S3 aborts a multipart upload, it deletes all parts associated with the multipart upload.

The underlying configuration is expressed in whole numbers of days. Providing a Duration that does not represent a whole number of days will result in a runtime or deployment error.

enabledoptionalbooleanenabledoptionalboolenabledoptionalBooleanEnabledoptionalboolEnabledoptional*bool= true#
Whether this rule is enabled.
expirationoptionalDurationexpirationoptionalDurationexpirationoptionalDurationExpirationoptionalDurationExpirationoptionalDuration#
Indicates the number of days after creation when objects are deleted from Amazon S3 and Amazon Glacier.

Default: No expiration timeout

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.

The underlying configuration is expressed in whole numbers of days. Providing a Duration that does not represent a whole number of days will result in a runtime or deployment error.

expirationDateoptionaldateexpiration_dateoptionaldatetimeexpirationDateoptionalInstantExpirationDateoptionalDateTimeExpirationDateoptional*time.Time#
Indicates when objects are deleted from Amazon S3 and Amazon Glacier.

Default: No expiration date

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.

expiredObjectDeleteMarkeroptionalbooleanexpired_object_delete_markeroptionalboolexpiredObjectDeleteMarkeroptionalBooleanExpiredObjectDeleteMarkeroptionalboolExpiredObjectDeleteMarkeroptional*bool= false#
Indicates whether Amazon S3 will remove a delete marker with no noncurrent versions.

If set to true, the delete marker will be expired.

idoptionalstringidoptionalstridoptionalStringIdoptionalstringIdoptional*string#
A unique identifier for this rule.

The value cannot be more than 255 characters.

noncurrentVersionExpirationoptionalDurationnoncurrent_version_expirationoptionalDurationnoncurrentVersionExpirationoptionalDurationNoncurrentVersionExpirationoptionalDurationNoncurrentVersionExpirationoptionalDuration#
Time between when a new version of the object is uploaded to the bucket and when old versions of the object expire.

Default: No noncurrent version expiration

notes

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.

The underlying configuration is expressed in whole numbers of days. Providing a Duration that does not represent a whole number of days will result in a runtime or deployment error.

noncurrentVersionsToRetainoptionalnumbernoncurrent_versions_to_retainoptionalint | floatnoncurrentVersionsToRetainoptionalNumberNoncurrentVersionsToRetainoptionaldoubleNoncurrentVersionsToRetainoptional*float64#
Indicates a maximum number of noncurrent versions to retain.

Default: No noncurrent versions to retain

If there are this many more noncurrent versions, Amazon S3 permanently deletes them.

noncurrentVersionTransitionsoptionalNoncurrentVersionTransition[]noncurrent_version_transitionsoptionaltyping.List[NoncurrentVersionTransition]noncurrentVersionTransitionsoptionalList<NoncurrentVersionTransition>NoncurrentVersionTransitionsoptionalNoncurrentVersionTransition[]NoncurrentVersionTransitionsoptional*[]NoncurrentVersionTransition#
One or more transition rules that specify when non-current objects transition to a specified storage class.

Only for buckets with versioning enabled (or suspended).

If you specify a transition and expiration time, the expiration time must be later than the transition time.

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

Default: No rule

Objects must be larger than this value in bytes.

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

Default: No rule

Objects must be smaller than this value in bytes.

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

Default: Rule applies to all objects

tagFiltersoptional{ [key: string]: any }tag_filtersoptionaltyping.Mapping[str, Any]tagFiltersoptionalMap<String, Object>TagFiltersoptionalIDictionary<string, object>TagFiltersoptional*map[string]interface{}#
The TagFilter property type specifies tags to use to identify a subset of objects for an Amazon S3 bucket.

Default: Rule applies to all objects

transitionsoptionalTransition[]transitionsoptionaltyping.List[Transition]transitionsoptionalList<Transition>TransitionsoptionalTransition[]Transitionsoptional*[]Transition#
One or more transition rules that specify when an object transitions to a specified storage class.

Default: No transition rules

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.