LifecycleRule

class aws_cdk.aws_s3.LifecycleRule(*, abort_incomplete_multipart_upload_after=None, enabled=None, expiration=None, expiration_date=None, expired_object_delete_marker=None, id=None, noncurrent_version_expiration=None, noncurrent_versions_to_retain=None, noncurrent_version_transitions=None, object_size_greater_than=None, object_size_less_than=None, prefix=None, tag_filters=None, transitions=None)

Bases: object

Declaration of a Life cycle rule.

Parameters:
  • abort_incomplete_multipart_upload_after (Optional[Duration]) – Specifies a lifecycle rule that aborts incomplete multipart uploads to an Amazon S3 bucket. 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. Default: - Incomplete uploads are never aborted

  • enabled (Optional[bool]) – Whether this rule is enabled. Default: true

  • expiration (Optional[Duration]) – Indicates the number of days after creation when objects are deleted from Amazon S3 and Amazon 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. 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. Default: - No expiration timeout

  • expiration_date (Optional[datetime]) – Indicates when objects are deleted from Amazon S3 and Amazon Glacier. 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. Default: - No expiration date

  • expired_object_delete_marker (Optional[bool]) – Indicates whether Amazon S3 will remove a delete marker with no noncurrent versions. If set to true, the delete marker will be expired. Default: false

  • id (Optional[str]) – A unique identifier for this rule. The value cannot be more than 255 characters.

  • noncurrent_version_expiration (Optional[Duration]) – Time between when a new version of the object is uploaded to the bucket and when old versions of the object expire. 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. Default: - No noncurrent version expiration

  • noncurrent_versions_to_retain (Union[int, float, None]) – Indicates a maximum number of noncurrent versions to retain. If there are this many more noncurrent versions, Amazon S3 permanently deletes them. Default: - No noncurrent versions to retain

  • noncurrent_version_transitions (Optional[Sequence[Union[NoncurrentVersionTransition, Dict[str, Any]]]]) – One or more transition rules that specify when non-current objects transition to a specified storage class. Only for 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.

  • object_size_greater_than (Union[int, float, None]) – Specifies the minimum object size in bytes for this rule to apply to. Objects must be larger than this value in bytes. Default: - No rule

  • object_size_less_than (Union[int, float, None]) – Specifies the maximum object size in bytes for this rule to apply to. Objects must be smaller than this value in bytes. Default: - No rule

  • prefix (Optional[str]) – Object key prefix that identifies one or more objects to which this rule applies. Default: - Rule applies to all objects

  • tag_filters (Optional[Mapping[str, 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 (Optional[Sequence[Union[Transition, Dict[str, Any]]]]) – One or more transition rules that specify 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. Default: - No transition rules

ExampleMetadata:

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk as cdk
from aws_cdk import aws_s3 as s3

# storage_class: s3.StorageClass
# tag_filters: Any

lifecycle_rule = s3.LifecycleRule(
    abort_incomplete_multipart_upload_after=cdk.Duration.minutes(30),
    enabled=False,
    expiration=cdk.Duration.minutes(30),
    expiration_date=Date(),
    expired_object_delete_marker=False,
    id="id",
    noncurrent_version_expiration=cdk.Duration.minutes(30),
    noncurrent_versions_to_retain=123,
    noncurrent_version_transitions=[s3.NoncurrentVersionTransition(
        storage_class=storage_class,
        transition_after=cdk.Duration.minutes(30),

        # the properties below are optional
        noncurrent_versions_to_retain=123
    )],
    object_size_greater_than=123,
    object_size_less_than=123,
    prefix="prefix",
    tag_filters={
        "tag_filters_key": tag_filters
    },
    transitions=[s3.Transition(
        storage_class=storage_class,

        # the properties below are optional
        transition_after=cdk.Duration.minutes(30),
        transition_date=Date()
    )]
)

Attributes

abort_incomplete_multipart_upload_after

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

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.

Default:
  • Incomplete uploads are never aborted

enabled

Whether this rule is enabled.

Default:

true

expiration

Indicates the number of days after creation when objects are deleted from Amazon S3 and Amazon 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.

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.

Default:
  • No expiration timeout

expiration_date

Indicates when objects are deleted from Amazon S3 and Amazon Glacier.

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.

Default:
  • No expiration date

expired_object_delete_marker

Indicates whether Amazon S3 will remove a delete marker with no noncurrent versions.

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

Default:

false

id

A unique identifier for this rule.

The value cannot be more than 255 characters.

noncurrent_version_expiration

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

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.

Default:
  • No noncurrent version expiration

noncurrent_version_transitions

One or more transition rules that specify when non-current objects transition to a specified storage class.

Only for 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.

noncurrent_versions_to_retain

Indicates a maximum number of noncurrent versions to retain.

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

Default:
  • No noncurrent versions to retain

object_size_greater_than

Specifies the minimum object size in bytes for this rule to apply to.

Objects must be larger than this value in bytes.

Default:
  • No rule

object_size_less_than

Specifies the maximum object size in bytes for this rule to apply to.

Objects must be smaller than this value in bytes.

Default:
  • No rule

prefix

Object key prefix that identifies one or more objects to which this rule applies.

Default:
  • Rule applies to all objects

tag_filters

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

One or more transition rules that specify 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.

Default:
  • No transition rules