S3 versioning, lifecycle and storage classes
Keeping and expiring object versions, delete markers, lifecycle rules, and choosing between Standard, infrequent access and Glacier classes.
S3 versioning, lifecycle and storage classes
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- With versioning on, an overwrite keeps the old version and a plain delete only adds a delete marker. Versioning can be suspended later but never removed.
- Every version is stored and billed in full, so versioning needs a lifecycle rule that expires noncurrent versions.
- Colder classes cost less to store and more to touch: retrieval fees, minimum storage durations, minimum billable sizes and, for two of them, a restore step.
- Intelligent-Tiering moves objects by observed access with no retrieval fees, for a monitoring charge per object. It fits unknown or changing patterns.
- Lifecycle rules transition and expire objects by age. By default they skip objects under 128 KB, and each transition is a billed request.
- Add a rule that aborts incomplete multipart uploads, because their parts are billed and invisible in a normal listing.
Two problems that pull against each other
First, people overwrite and delete things by mistake, and so does code. You want the old copy back. Second, data piles up, most of it is never read again, and you pay for every byte every month. Versioning solves the first and makes the second worse. Lifecycle rules and storage classes solve the second.
Versioning and delete markers
A bucket is unversioned, versioning-enabled or versioning-suspended. Once enabled it can be suspended but never returned to unversioned.
With it on, every write to a key creates a new version with its own ID. A DELETE without a version ID removes nothing. It adds a delete marker that becomes the current version, so the object looks gone. On a local emulator:
$ aws s3api put-object ... --key price.txt # VersionId 10d8...
$ aws s3api put-object ... --key price.txt # VersionId f1c7...
$ aws s3api delete-object ... --key price.txt
{ "DeleteMarker": true, "VersionId": "9049..." }
$ aws s3api get-object ... --key price.txt out.txt
An error occurred (NoSuchKey) ...
$ aws s3api list-object-versions ... --prefix price.txt
Versions: f1c7... (not latest), 10d8... (not latest)
DeleteMarkers: 9049... (latest)
Both versions are still there. Remove the marker and the newest one reappears. Only a delete that names a version ID destroys data, which is why s3:DeleteObjectVersion should be a rare permission. Object Lock goes further and blocks deletion for a retention period, for compliance and ransomware defence.
Each version is a full copy, not a diff. Rewrite a 1 GB file daily for a month and you’re storing about 30 GB.
Storage classes
All classes below keep the same API. They differ in price shape and in how many Availability Zones hold the data. Standard, Standard-IA, Intelligent-Tiering and the Glacier classes are all designed for eleven nines of durability.
| Class | Reading it | Minimum duration | Zones |
|---|---|---|---|
| Standard | milliseconds | none | 3 or more |
| Standard-IA | milliseconds, retrieval fee | 30 days | 3 or more |
| One Zone-IA | milliseconds, retrieval fee | 30 days | 1 |
| Glacier Instant Retrieval | milliseconds, higher fee | 90 days | 3 or more |
| Glacier Flexible Retrieval | restore first, minutes to hours | 90 days | 3 or more |
| Glacier Deep Archive | restore first, hours | 180 days | 3 or more |
The infrequent access and instant retrieval classes also bill small objects as if they were 128 KB. Use One Zone-IA only for data you can rebuild, because losing that zone loses it. Express One Zone is a separate high-speed, single-zone class for latency-sensitive work.
The colder the class, the cheaper the shelf and the dearer the trip to it. It’s off-site box storage: fine for tax records, silly for the stapler.
Intelligent-Tiering is the answer when you don’t know the access pattern. It moves an object to an infrequent tier after 30 days without access and an archive instant tier after 90, and back when it’s read. There are no retrieval fees, but there’s a monitoring charge per object, and objects under 128 KB aren’t moved. Optional deeper archive tiers need a restore, so enable them only if your application can wait.
Lifecycle rules
A lifecycle configuration is a list of rules that S3 applies in the background, filtered by prefix, tag or size:
{ "Rules": [ {
"ID": "logs", "Status": "Enabled", "Filter": { "Prefix": "logs/" },
"Transitions": [
{ "Days": 30, "StorageClass": "STANDARD_IA" },
{ "Days": 90, "StorageClass": "GLACIER_IR" },
{ "Days": 365, "StorageClass": "DEEP_ARCHIVE" } ],
"Expiration": { "Days": 2555 },
"NoncurrentVersionExpiration":
{ "NoncurrentDays": 90, "NewerNoncurrentVersions": 3 },
"AbortIncompleteMultipartUpload": { "DaysAfterInitiation": 7 }
} ] }
Read it as: cool logs down over a year, delete them after about seven, keep at least the three newest old versions and drop older ones 90 days after they’re replaced, and clean up abandoned multipart uploads after a week.
In a versioned bucket, Expiration on the current version only adds a delete marker. The noncurrent rule is what frees space. Transitions move one way toward colder classes, must respect each class’s minimum duration, and each is a billed request. Rules act asynchronously, so don’t expect objects to move at the exact minute.
Choosing
Ask three questions. How often is it read? How fast must a read be? How long will it exist? Short-lived or busy data stays in Standard. Unknown patterns go to Intelligent-Tiering. Known cold data goes down the table. Check cost tools before and after, since request and retrieval charges can eat a storage saving.
About the video
The embed is AWS’s own 11-minute “Understanding Amazon S3 Lifecycle Management Policies” from March 2024. Its chapters cover storage classes, a worked example and a console demo. It doesn’t teach versioning or delete markers; the runner-up from Enrico Portolan in the links does. I judged it from chapters and description only. There’s no audio-language flag; title, description and captions are English.
The version listing ran on moto 5.1.22, an emulator, and moto also accepted the lifecycle JSON. It doesn’t move objects or bill anyone. Class properties and transition rules come from the S3 user guide, checked in November 2026.
Check yourself
A versioned bucket's object was deleted with a normal DELETE. How do you get it back?
Delete the delete marker, by specifying its version ID. The previous version becomes current again. You could also copy a specific old version over the key.
You move logs to Glacier Instant Retrieval and delete them after 20 days. What does it cost you?
You're still charged as if they stayed 90 days, its minimum storage duration. Data that short-lived belongs in Standard.
A bucket holds millions of 10 KB files and you add a transition to Standard-IA. Why might nothing move, and why is that probably good?
By default lifecycle won't transition objects under 128 KB. Moving them would cost a transition request each and they'd be billed as 128 KB, likely more than the saving.
Someone with s3:DeleteObjectVersion removes every version. Did versioning protect you?
No. Versioning guards against overwrites and simple deletes. Against a privileged or malicious delete you need tighter permissions, MFA delete, Object Lock or a copy in another account.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.