Supported actions
AI Object Storage supports the following lifecycle actions:Expiration: Delete current object versions when they reach a given age, on a specific date, or after they become an expired delete marker.NoncurrentVersionExpiration: For versioned buckets, delete noncurrent object versions when they reach a given age. Optionally retain a fixed number of newer noncurrent versions.AbortIncompleteMultipartUpload: Permanently abort multipart uploads that have not completed within a given number of days after initiation, removing all uploaded parts.
Transition actions, which move objects between storage classes, are not supported. AI Object Storage manages storage tiering automatically based on access patterns. See Cost management for details.
Key behaviors
Read these behaviors before designing a lifecycle policy.- Object age is measured from creation time, not last access time. A
Days: 7rule deletes an object 7 days after it was uploaded, regardless of how recently it was read. To target objects by access pattern, use the tier-based pricing model instead. - Eligibility is evaluated at UTC midnight day boundaries; once eligible, objects are processed within roughly an hour. Eligibility is calculated by truncating
creationTime + Daysto midnight UTC. ADays: 7rule on an object uploaded at 14:00 UTC on day 1 makes it eligible at midnight UTC on day 8. The lifecycle processor runs approximately every hour — once the midnight UTC eligibility date has passed, the object is processed in the next hourly run. Storage fees continue to accrue until the physical deletion completes. - Versioning interacts with
Expiration. On a versioning-enabled bucket, anExpirationrule does not permanently delete objects — it writes a delete marker, making the current version noncurrent. On a versioning-suspended bucket, expiration creates a delete marker with a null version ID; if the current version already has a null version ID, it is permanently replaced. To permanently remove data in either case, also configureNoncurrentVersionExpiration. - Putting a configuration replaces the existing one.
s3:PutBucketLifecycleConfigurationoverwrites the entire lifecycle configuration for a bucket. Always send the full set of rules you want enforced. - Each bucket can have up to 1,000 lifecycle rules. See Manage quotas and limits for the full limits table.
- Disabling or deleting a rule unschedules pending expirations. If a rule is disabled or removed, objects that were already queued for expiration are unscheduled and are not deleted.
- When multiple rules match the same object on the same day, the most aggressive action wins. Permanent deletion takes precedence over creating a delete marker. If two expiration rules overlap, the shorter expiration period is applied. When a broad rule (empty prefix) and a narrower rule (specific prefix) both match, both run independently.
Rule filters
A rule’sFilter selects which objects the rule applies to. A rule with an empty filter applies to every object in the bucket.
Prefix filter
A prefix filter applies the rule to objects whose keys start with the given prefix. Use prefix filters to scope rules to a folder-like portion of a bucket.Apply only to objects under the logs/ prefix
Tag filter
A tag filter applies the rule to objects that carry a specific object tag. Use tag filters when objects you want to expire are not grouped by key prefix.Apply only to objects tagged temp=true
And. Objects with additional tags beyond those listed still match.
Apply only to objects tagged environment=dev AND team=ml-training
Size filter
A size filter matches objects whose size falls within a specified range. Both boundaries are exclusive — objects exactly at the boundary value are not matched. Values are in bytes.Apply only to objects larger than 1 MB and smaller than 100 MB
And. See Combined filter below.
Combined filter
A rule can combine a prefix, multiple tags, and object size constraints by wrapping them inAnd.
Apply to large objects under archive/ tagged class=cold
Common configurations
The following configurations cover the most common use cases. Each configuration is a complete, valid lifecycle document you can apply to a bucket as is.- Expire objects after 7 days
- Expire noncurrent versions
- Abort incomplete multipart uploads
- Expire objects on a fixed date
- ML training retention policy
This configuration expires every object in the bucket 7 days after it is uploaded.
Expire all objects 7 days after creation
Rules array.
Apply a lifecycle configuration
Save the lifecycle configuration to a file, then apply it to your bucket using one of the following clients.- AWS CLI
- s3cmd
- Boto3
-
Save the configuration to a local file, for example
lifecycle.json. -
Apply the configuration. Replace
[BUCKET-NAME]with the name of your bucket.Apply a lifecycle configuration with AWS CLI
Verify a lifecycle configuration
Confirm the active configuration on a bucket. To check when a specific object will expire, use theHeadObject (AWS CLI: head-object) or GetObject API — the response includes an x-amz-expiration header with the expiration date and the rule ID that applies to the object.
- AWS CLI
- s3cmd
- Boto3
Get the active lifecycle configuration with AWS CLI
Delete a lifecycle configuration
Removing the lifecycle configuration stops all automated lifecycle actions on the bucket. Objects that were already queued for expiration are unscheduled and are not deleted.- AWS CLI
- s3cmd
- Boto3
Delete the lifecycle configuration with AWS CLI
Rule field reference
The following fields are available in a lifecycle rule:| Field | Description |
|---|---|
ID | Identifier for the rule. Up to 255 characters. |
Filter | Selects which objects the rule applies to. Contains a Prefix, Tag, or And clause. An empty filter matches every object in the bucket. |
Filter.Prefix | Object key prefix to match. For example, foo/ matches both foo/bar and foo/baz. |
Filter.Tag | A single tag key/value pair to match. |
Filter.And | Combines a prefix, multiple tags, and object size constraints in one filter. |
Filter.ObjectSizeGreaterThan | Minimum object size, in bytes. |
Filter.ObjectSizeLessThan | Maximum object size, in bytes. |
Status | Enabled or Disabled. Disabled rules do not run. |
Expiration | Deletes the current version of matching objects when they reach a given age (Days), on a specific UTC date in ISO 8601 format (Date), or when an expired delete marker is present (ExpiredObjectDeleteMarker). |
Expiration.ExpiredObjectDeleteMarker | If true, removes a delete marker that has no remaining noncurrent versions. Cannot be combined with Days or Date. |
NoncurrentVersionExpiration | On versioned buckets, deletes noncurrent versions after NoncurrentDays. Optionally retains NewerNoncurrentVersions of the most recent noncurrent versions. |
AbortIncompleteMultipartUpload | Aborts multipart uploads that have not completed DaysAfterInitiation days after they were started. |
Common questions
Can I recover objects that were deleted by a lifecycle rule? In a non-versioned bucket, no — expired objects are permanently deleted. In a versioning-enabled bucket, anExpiration rule creates a delete marker rather than permanently deleting the object, so you can restore a previous version by copying it back as the current version. Enable versioning before configuring expiration rules if you need recoverability.
Can I use multiple prefixes in a single rule?
No. A single lifecycle rule supports only one prefix. To apply the same action to objects under multiple prefixes, either create a separate rule for each prefix, or use object tags to group objects under a tag-based filter.
Can I exclude a prefix from a lifecycle rule?
Lifecycle rules do not support exclusion filters. Use object tags to mark the objects you want to include, then create a tag-based rule that targets them rather than trying to exclude objects by prefix.
Do lifecycle rules apply to objects that already exist in the bucket?
Yes. When you add or update a lifecycle configuration, rules apply to both existing and newly created objects. Existing objects that already meet the expiration criteria are queued for removal immediately.
What happens when I update a lifecycle configuration?
PutBucketLifecycleConfiguration replaces the entire existing configuration. To add or modify a single rule, retrieve the current configuration first, make your changes, and then put the updated configuration back.
Related
- Empty and delete a bucket: Use a lifecycle policy to keep buckets ready for deletion.
- Abort incomplete multipart uploads: Locate and clean up incomplete multipart uploads before applying a recurring rule.
- Versioned buckets: Manage versioned buckets and noncurrent versions.
- Manage AI Object Storage with Terraform: Apply lifecycle configurations as code, including a known issue with
NoncurrentVersionTransitionsin version 0.7.0 of the CoreWeave provider. - S3 API compatibility: Reference notes for
PutBucketLifecycleConfiguration,GetBucketLifecycleConfiguration, andDeleteBucketLifecycle.