Skip to navigation

Lifecycle rules

Delete old files, old versions and unfinished uploads automatically.

A lifecycle rule deletes things in a bucket automatically after a number of days: files, old versions, leftover delete markers and unfinished uploads. Use rules to keep storage, and your bill, under control without deleting files by hand.

You manage rules in the console under Buckets > the bucket’s Bucket Settings (gear icon) > Lifecycle Rules. From there you can add rules, edit them, turn them on or off, and delete them.

Rules run once a day on the storage cluster. A new or changed rule takes effect within 24 to 48 hours, and it also applies to files that already exist and match.

What a rule can do

A rule has one or more cleanup actions, and each action has its own number of days.

ActionWhat it deletesFrees space?Needs versioning?Can’t be in the same rule as
Expire objectsFiles, a set number of days after uploadOnly if versioning was never onNoTidy delete markers
Clear old versionsOld versions, a set number of days after a newer version replaced themYesYes—
Tidy delete markersDelete markers that have no versions left behind themA littleYesExpire objects, tag or size filters
Discard unfinished uploadsParts of uploads that never finished, a set number of days after they startedYesNoTag or size filters

Needs versioning means versioning is on for the bucket, or was on and is now turned off. If versioning was never turned on, the console doesn’t show those two actions. See Versioning.

Expire objects

Deletes files a set number of days after they were uploaded.

  • Versioning never turned on: the file is deleted for good.
  • Versioning on (or turned off later): the file is not deleted. Zata adds a delete marker on top of it, so the file disappears from the file list, but its data stays as an old version and still uses storage. To free that space, add Clear old versions too. See How versioning changes what a rule does.
New lifecycle rule step 1 with Expire objects ticked and after 30 days entered. Tidy delete markers is greyed out with the note Not available in the same rule as Expire objects

While Expire objects is ticked, Tidy delete markers is greyed out: the two can’t be in the same rule. Put them in two rules instead.

Clear old versions

Deletes old versions for good, a set number of days after a newer version replaced them or the file was deleted. This is the only action that frees space in a versioned bucket. The days count from the moment a version became old, not from its upload.

New lifecycle rule step 1 with Clear old versions ticked and after 30 days entered

Keep newest (Mumbai only): in Mumbai buckets, Clear old versions also has a keep newest box. Enter a number from 1 to 100 to always keep that many of the most recent old versions of each file. For example, 10 days and keep newest 3 deletes old versions after 10 days but always keeps the 3 most recent ones. Leave it empty to delete every old version after the days. Buckets in Indore don’t have this option.

Tidy delete markers

When a file is deleted in a versioned bucket, Zata leaves a delete marker. Once all the file’s old versions are gone, for example after Clear old versions removed them, the marker is all that is left. This action removes those leftover markers, so the file is gone from the bucket completely. It has no number of days.

New lifecycle rule step 1 with only Tidy delete markers ticked

It can’t be in the same rule as Expire objects, and it can’t be used with tag or size filters. A key prefix is fine.

Discard unfinished uploads

Large files are uploaded in parts (a multipart upload). If an upload is interrupted, for example by a network failure, and never finished or cancelled, its parts stay in the bucket. They use storage but don’t show in the file list, and they stop you from deleting the bucket. This action removes them a set number of days after the upload started.

New lifecycle rule step 1 with Discard unfinished uploads ticked and after 7 days entered

A Discard unfinished uploads rule of 7 days on the entire bucket is a good idea for every bucket that receives large uploads. It can’t be used with tag or size filters.

How versioning changes what a rule does

In a versioned bucket, nothing is deleted for good by Expire objects alone. This is the most common reason storage doesn’t go down after adding a rule.

Versioning never turned onVersioning on, or turned off later
Expire objectsDeletes the file for goodHides the file behind a delete marker. Its data stays as an old version.
Clear old versionsNot shownDeletes old versions for good
Tidy delete markersNot shownRemoves markers with no versions left
Discard unfinished uploadsRemoves unfinished uploadsRemoves unfinished uploads

To delete files after 30 days in a versioned bucket and free the space, use two rules:

  1. Expire objects 30 days and Clear old versions 7 days.
  2. Tidy delete markers, on its own (it can’t share a rule with Expire objects).

What happens to a file uploaded on day 0:

  • Day 30: the file is hidden behind a delete marker. It can still be restored from its old version.
  • Day 37: the old version is deleted for good and its space is freed.
  • A later daily run: the leftover delete marker is removed.

The 7 days in step 1 are your safety window: until then you can still restore the file. Use fewer days to free space sooner, or more to keep a longer window.

Add a rule

1

Open Lifecycle Rules

Go to Buckets, select the gear icon (Bucket Settings) of the bucket, expand Lifecycle Rules and select Add lifecycle rule.

The Lifecycle Rules section in Bucket Settings with the Add lifecycle rule button
2

Choose what to clean up

A panel opens: New lifecycle rule, Step 1 of 2. Under What should this rule clean up?, tick one or more actions and enter the number of days for each (a whole number from 1 to 36,500). You can tick several actions in one rule. Select Next.

Next stays greyed out until at least one action is ticked and has its days filled in.

Step 1 of the new rule with Expire objects, Clear old versions and Discard unfinished uploads ticked
3

Choose which files it applies to

Under Which objects does it apply to?, choose:

  • Entire bucket: every file, now and in the future.
  • Filtered subset: only files that match the filters you set. See Which files a rule applies to.
Step 2 with Entire bucket selected and the This rule will summary
4

Check the summary and create the rule

The summary under This rule will: lists what the rule will do. Check it and select Create rule. Select Back to change the actions.

The console names the rule for you from what it does, for example expire-3f9a1c, versions-…, markers-…, uploads-…, or cleanup-… for a rule with several actions.

Only Cancel or the ✕ closes the panel, and closing it discards what you entered.

Which files a rule applies to

With Filtered subset, a file must match every filter you set.

Step 2 with Filtered subset selected, showing the Key prefix and Object tags fields
FilterHow it works
Key prefixOnly files whose name (path) starts with this text. For a folder, end it with a slash: logs/ matches logs/2026/app.log. Capital letters matter: Logs/ doesn’t match logs/. Select the folder button to pick an existing folder.
Object tagsOnly files that carry all the listed tags (key and value). Up to 10 tags. Files without the tags are not touched. See Tags.
Object size (Mumbai only)Larger than and Smaller than, in B, KB, MB or GB (1 KB = 1,024 bytes). Leave one empty for no limit. Files exactly the size you enter don’t match.

Tag and size filters can’t be combined with Tidy delete markers or Discard unfinished uploads. If you ticked one of those in step 1 and then add a tag or size filter, it is left out of the rule. Check the This rule will: summary before you create the rule. A key prefix works with every action.

Edit, turn off or delete a rule

Each rule in the list shows its name, whether it is Enabled or Disabled, which files it applies to (for example prefix: logs/ or whole bucket) and what it does (for example expire after 30d or old versions after 30d (keep 3)).

A lifecycle rule in the list with its switch, edit and delete buttons pointed out
  • Turn off or on: use the switch. A turned-off rule stays in the list and does nothing until you turn it back on.
  • Edit: select the pencil. The same panel opens with the rule’s settings. Change them and select Save changes. The rule keeps its name.
  • Delete: select the bin, then Delete rule.

Turning off or deleting a rule stops its cleanup straight away. Files it has already deleted don’t come back.

Examples

GoalRules
Delete log files after 30 daysExpire objects 30 days, Filtered subset with key prefix logs/
Delete files after 30 days in a versioned bucket and free the spaceRule 1: Expire objects 30 days and Clear old versions 7 days. Rule 2: Tidy delete markers. See How versioning changes what a rule does.
Keep a versioned backup bucket from growingClear old versions 30 days and Discard unfinished uploads 7 days, Entire bucket. In Mumbai, add keep newest 3 to always keep the last 3 old versions.
Clean up failed large uploadsDiscard unfinished uploads 7 days, Entire bucket
Delete temporary files you tag yourselfExpire objects 1 day, Filtered subset with the tag temp = true
Delete large temporary files only (Mumbai)Expire objects 7 days, Filtered subset with key prefix tmp/ and Larger than 100 MB
Empty a bucket before deleting itSee Delete a large bucket

When files are actually deleted

  • The days count from the file’s upload, from the moment a version became old (Clear old versions), or from the start of the upload (Discard unfinished uploads).
  • Deleting happens in the daily run after the days have passed, so a file can stay up to a day or two longer than the number of days you entered.
  • A new rule also applies to files that already exist. A 30-day rule added to a bucket with year-old files deletes those files in its first run.
  • Space is freed when the run deletes the data, not when you save the rule.
  • In a bucket with Object Lock, versions under a retention period or legal hold are skipped until the lock ends. The Lifecycle Rules section shows a note about this on such buckets.

Set rules with S3 tools

You can also manage rules through the S3 API, for example with the AWS CLI. Use the account owner’s access key: a sub-user’s key gets Access Denied.

Save the rules to a file, for example lifecycle.json:

lifecycle.json
{
"Rules": [
{
"ID": "logs-cleanup",
"Status": "Enabled",
"Filter": { "Prefix": "logs/" },
"Expiration": { "Days": 30 },
"AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
}
]
}

Then apply, read or remove them:

# Apply the rules (this REPLACES every rule on the bucket)
aws s3api put-bucket-lifecycle-configuration --bucket my-bucket \
--lifecycle-configuration file://lifecycle.json --profile zata
# Show the rules on the bucket
aws s3api get-bucket-lifecycle-configuration --bucket my-bucket --profile zata
# Remove all rules from the bucket
aws s3api delete-bucket-lifecycle --bucket my-bucket --profile zata
  • Applying replaces all rules. Include the bucket’s existing rules in the file, or they are removed. The console works the same way behind the scenes.
  • Supported: Expiration with Days or ExpiredObjectDeleteMarker, NoncurrentVersionExpiration, AbortIncompleteMultipartUpload, and filters by Prefix, Tag and And.
  • Mumbai only: NewerNoncurrentVersions (keep newest) and ObjectSizeGreaterThan / ObjectSizeLessThan.
  • Not supported: Transitions (Zata has one storage class).

In Indore, don’t send ObjectSizeGreaterThan, ObjectSizeLessThan or NewerNoncurrentVersions from an S3 tool. Indore’s storage ignores them without an error. A size-filtered rule then applies to every file that matches the rest of its filter, and “keep newest” keeps nothing. The console doesn’t offer these options in Indore for this reason.

A rule that uses options the console doesn’t support, such as an expiry on a fixed Date, is marked External in the console. See Troubleshooting.

Ask Zata Assistant

Zata Assistant can set up simple rules for you. Ask, for example, “delete files in the logs folder of my-bucket after 30 days”. It opens a card with the rule filled in, and nothing is saved until you select Save rule.

The assistant’s card covers the whole bucket or one folder, with Delete files after, Delete old versions after (versioned buckets) and Cancel unfinished uploads after. For Tidy delete markers, keep newest, and tag or size filters, use Lifecycle Rules in Bucket Settings. Only the account owner can change rules, and changes need a paid plan.

Troubleshooting

  • Wait 24 to 48 hours. Rules run once a day.
  • Check the days: they count from the upload, or from when a version became old.
  • Check the filter: the key prefix must match the start of the path exactly, capital letters included, and a file must carry all the listed tags.
  • In a versioned bucket, Expire objects only hides files. They still appear when you show versions.
  • In a bucket with Object Lock, locked versions are skipped until their lock ends.

The bucket is probably versioned. Expire objects keeps the data as old versions, so add Clear old versions as shown in How versioning changes what a rule does. Unfinished uploads also use storage without showing in the file list: add Discard unfinished uploads.

Versioning was never turned on for this bucket. These actions only appear for buckets where versioning is on, or was on.

  • Tidy delete markers is greyed out while Expire objects is ticked. Create a separate rule for it.
  • In step 2, tag and size filters remove Tidy delete markers and Discard unfinished uploads from the rule. Use a key prefix or Entire bucket for those actions.

The bucket is in Indore. These options are available in Mumbai only.

At least one rule on the bucket was added with an S3 tool and uses options the console doesn’t support, such as a storage-class transition or an expiry on a fixed date. To avoid overwriting it, the console then shows all the bucket’s rules read-only and hides Add lifecycle rule. Manage the rules with the tool you used, or remove them all with aws s3api delete-bucket-lifecycle and create them again in the console.

Someone changed the bucket’s rules elsewhere, for example with an S3 tool or in another browser tab, while you had the page open. The list has been refreshed: check it and make your change again.

A bucket can have up to 20 rules. Delete rules you don’t need, or combine several actions into one rule.

Only the account owner can manage lifecycle rules. The section is hidden for sub-users, and a sub-user’s access key gets Access Denied.

Limits

Rules per bucket20
DaysWhole number, 1 to 36,500
keep newest1 to 100 old versions, Mumbai only
Tags per ruleUp to 10. Key up to 128 characters, value up to 256.
Key prefixUp to 1,024 characters
Object size filterMumbai only
Storage classesOne, so rules can’t move files to another storage class
Who can manage rulesThe account owner