- Newest
- Most votes
- Most comments
Based on your situation, there are a few key points to understand about S3 lifecycle rules with versioned buckets:
-
When versioning is enabled, the "days after becoming noncurrent" counter starts when an object version becomes noncurrent, not when it was created. In your case, the object was created on 2023-09-28, but it only became noncurrent when the delete marker was added on 2023-12-28. This means the noncurrent version expiration countdown started from December 28, not from the original creation date.
-
S3 lifecycle rules are processed asynchronously and typically run once per day starting at midnight UTC. There can be delays in processing, especially with large amounts of data.
-
For your specific configuration, you need to ensure you have rules to handle both aspects of versioned objects:
- The rule to expire current versions (which creates delete markers)
- The rule to permanently delete noncurrent versions
- A rule to delete expired object delete markers (this appears to be missing in your configuration)
To fully clean up both the delete markers and the noncurrent versions, you should add the "ExpiredObjectDeleteMarker" setting to your lifecycle rules. This will remove delete markers that have become the only remaining version of an object.
Your lifecycle configuration should include something like:
"ExpiredObjectDeleteMarker": {
"Status": "Enabled"
}
This will ensure that once the noncurrent versions are deleted, the orphaned delete markers will also be removed.
If you want to monitor the lifecycle rule actions, you can enable S3 server access logging or use CloudTrail data events for S3, though these might generate significant volumes of logs.
Sources
Lifecycle rules setup on s3 versions enabled is not cleaning up prefixes | AWS re:Post
S3-lifecycle to auto-delete old object-versions: configuration? | AWS re:Post
When versioning is enabled, S3 lifecycle expiration behaves differently because deleting an object only adds a delete marker—it doesn’t remove the underlying versions. Your updated rule must explicitly handle both current and noncurrent object versions. The Expiration action only affects the current version, while NoncurrentVersionExpiration controls how long to retain older versions. If you want objects, including all versions, to be permanently deleted after a given time, you must include both. For example, set Expiration for 90 days and NoncurrentVersionExpiration for 90 days as well, ensuring both have Status: Enabled and the correct prefix filter.
—Taz
answered a year ago
Thanks for your answer, but isn't it what I have shown in the rules above?
If not, what have I missed?
"NoncurrentVersionExpiration": {
"NoncurrentDays": 5,
"NewerNoncurrentVersions": 1
}
This rule really means that you are keeping one non-current version. That is, in total, you will keep the current (latest) version plus one more version of the objects.
Regarding deleting delete markers, you can add an additional rule to clean it up.
{
"Rules": [
{
"ID": "cleanup-delete-markers",
"Status": "Enabled",
"Filter": {
"Prefix": ""
},
"DeleteMarkerReplication": "Disabled",
"Expiration": {
"ExpiredObjectDeleteMarker": true
}
}
]
}
This rule really means that you are keeping one non-current version. That is, in total, you will keep the current (latest) version plus one more version of the objects.
Well, ok, but I can't give a value of 0 the CLI refuses it and so does the Console or terraform. If I read this right, this mean that the current rule has no effect whatsoever on deleted objects?

The countdown started on December 28, right, but in 2023 which is 3 years ago, so clearly, the 5 days have long been gone.
I can't add ExpiredObjectDeleteMarker to my rules, even the console says it: You cannot enable Delete expired object delete markers if you enable Expire current versions of objects.
Should I add a fourth rule without any prefix to just activate this?