# LifecycleRule

Declaration of a Life cycle rule.

- Source: [`aws-s3/lib/rule.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-s3/lib/rule.ts#L6)
- Type last changed: v2.27.0 · 3 Jun 2022

## 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

- `abortIncompleteMultipartUploadAfter`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — Specifies a lifecycle rule that aborts incomplete multipart uploads to an Amazon S3 bucket.

  **Default:** Incomplete uploads are never aborted

  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.

- `enabled`: boolean = true — Whether this rule is enabled.

- `expiration`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — Indicates the number of days after creation when objects are deleted from Amazon S3 and Amazon Glacier.

  **Default:** No expiration timeout

  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.

- `expirationDate`: date — Indicates when objects are deleted from Amazon S3 and Amazon Glacier.

  **Default:** No expiration date

  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.

- `expiredObjectDeleteMarker`: boolean = false — Indicates whether Amazon S3 will remove a delete marker with no noncurrent versions.

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

- `id`: string — A unique identifier for this rule.

  The value cannot be more than 255 characters.

- `noncurrentVersionExpiration`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — 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

  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.

- `noncurrentVersionsToRetain`: number — 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.

- `noncurrentVersionTransitions`: [NoncurrentVersionTransition](/cdk/api/v2/docs/aws-cdk-lib.aws_s3.NoncurrentVersionTransition.html)[] — 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.

- `objectSizeGreaterThan`: number — 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.

- `objectSizeLessThan`: number — 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.

- `prefix`: string — Object key prefix that identifies one or more objects to which this rule applies.

  **Default:** Rule applies to all objects

- `tagFilters`: { [key: string]: any } — 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

- `transitions`: [Transition](/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Transition.html)[] — 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.
