teluzia.Cloud Engineer · Day 57
CHAPTER 09 · STORAGE AND DATABASES

S3 versioning, lifecycle and policies

4–5 hours including independent practice3 topics
LET’S MAKE THIS SIMPLE

What you’re learning today

Experiment with recovery from an object overwrite and a delete marker in a dedicated S3 sandbox bucket. Versioning, lifecycle and bucket policy control different behaviors: retaining old content, changing its storage lifetime and authorizing requests. Your learner-run lab creates only synthetic objects and ends by removing all versions deliberately. With versioning enabled, an overwrite normally creates a new object version instead of erasing the older version. A simple delete creates a delete marker that hides the current object from ordinary reads. Older versions can still be addressed by version ID. Removing the marker can reveal the previous version again. Lifecycle rules can expire current objects, remove noncurrent versions and transition eligible data to storage classes. Rules operate asynchronously and have class-specific size, duration or other constraints. Current expiration in a versioned bucket differs from deleting all history. Retention must match recovery needs and compliance policy.

Think of it this way

Versioning is a stack of dated documents; lifecycle is the retention clerk; policy decides who may open or alter the cabinet.

TOPIC 01 / 03Step by step

Version IDs and delete markers

With versioning enabled, an overwrite normally creates a new object version instead of erasing the older version. A simple delete creates a delete marker that hides the current object from ordinary reads. Older versions can still be addressed by version ID. Removing the marker can reveal the previous version again. Writing v1 then v2 to notes.txt produces separate version IDs; a delete without a version ID hides the name, while GetObject using the recorded v1 ID can still retrieve the earlier body. Version-aware recovery protects against simple overwrite mistakes and explains why a bucket that appears empty in an ordinary listing may still contain stored and billed versions. Using ordinary object deletion as complete teardown leaves noncurrent versions and markers; inventory versions explicitly before claiming a versioned bucket is empty or no longer consuming storage.

WORKED EXAMPLE
Writing v1 then v2 to notes.txt produces separate version IDs; a delete without a version ID hides the name, while GetObject using the recorded v1 ID can still retrieve the earlier body.
Why this matters

Version-aware recovery protects against simple overwrite mistakes and explains why a bucket that appears empty in an ordinary listing may still contain stored and billed versions.

A common trap

Using ordinary object deletion as complete teardown leaves noncurrent versions and markers; inventory versions explicitly before claiming a versioned bucket is empty or no longer consuming storage.

Read all topics in this lesson

A complete reference to revisit alongside the guided steps above.

Version IDs and delete markers

With versioning enabled, an overwrite normally creates a new object version instead of erasing the older version. A simple delete creates a delete marker that hides the current object from ordinary reads. Older versions can still be addressed by version ID. Removing the marker can reveal the previous version again. Writing v1 then v2 to notes.txt produces separate version IDs; a delete without a version ID hides the name, while GetObject using the recorded v1 ID can still retrieve the earlier body. Version-aware recovery protects against simple overwrite mistakes and explains why a bucket that appears empty in an ordinary listing may still contain stored and billed versions. Using ordinary object deletion as complete teardown leaves noncurrent versions and markers; inventory versions explicitly before claiming a versioned bucket is empty or no longer consuming storage.

WORKED EXAMPLE
Writing v1 then v2 to notes.txt produces separate version IDs; a delete without a version ID hides the name, while GetObject using the recorded v1 ID can still retrieve the earlier body.

Why this matters

Version-aware recovery protects against simple overwrite mistakes and explains why a bucket that appears empty in an ordinary listing may still contain stored and billed versions.

A common trap

Using ordinary object deletion as complete teardown leaves noncurrent versions and markers; inventory versions explicitly before claiming a versioned bucket is empty or no longer consuming storage.

Lifecycle versions and transitions

Lifecycle rules can expire current objects, remove noncurrent versions and transition eligible data to storage classes. Rules operate asynchronously and have class-specific size, duration or other constraints. Current expiration in a versioned bucket differs from deleting all history. Retention must match recovery needs and compliance policy. A rule expiring current objects after 30 days does not by itself mean every noncurrent version is deleted after 30 days; define noncurrent-version expiration separately when that is the intended policy. Separate current and noncurrent rules keep retention promises accurate and prevent unlimited historical growth hidden behind an apparently short object-expiration configuration shown in a bucket settings screen. Applying a lifecycle rule to real data before modeling version behavior can permanently remove recovery history; test with synthetic keys and document the complete current/noncurrent retention contract.

WORKED EXAMPLE
A rule expiring current objects after 30 days does not by itself mean every noncurrent version is deleted after 30 days; define noncurrent-version expiration separately when that is the intended policy.

Why this matters

Separate current and noncurrent rules keep retention promises accurate and prevent unlimited historical growth hidden behind an apparently short object-expiration configuration shown in a bucket settings screen.

A common trap

Applying a lifecycle rule to real data before modeling version behavior can permanently remove recovery history; test with synthetic keys and document the complete current/noncurrent retention contract.

Bucket policy and safe administration

A bucket policy is resource-based authorization and combines with relevant IAM controls. Conditions such as aws:SecureTransport can deny insecure transport, but broad explicit denies can also lock out intended workflows. Restrict public exposure and keep policies reviewable. Versioning enables recovery but does not prevent authorized deletion of specific versions. A policy denying insecure requests must use both bucket and object resource ARNs for the intended actions; it is unrelated to whether a lifecycle rule retains an older notes.txt version. Separating authorization from retention helps investigate AccessDenied versus missing current objects and makes administrative deletion rights a conscious choice rather than an accidental consequence of a broad policy copied into the bucket. Assuming versioning is immutable backup overlooks permissions to delete versions; review DeleteObjectVersion and retention features separately rather than promising protected history solely because bucket versioning is enabled.

WORKED EXAMPLE
A policy denying insecure requests must use both bucket and object resource ARNs for the intended actions; it is unrelated to whether a lifecycle rule retains an older notes.txt version.

Why this matters

Separating authorization from retention helps investigate AccessDenied versus missing current objects and makes administrative deletion rights a conscious choice rather than an accidental consequence of a broad policy copied into the bucket.

A common trap

Assuming versioning is immutable backup overlooks permissions to delete versions; review DeleteObjectVersion and retention features separately rather than promising protected history solely because bucket versioning is enabled.

KEEP THESE WITH YOU

Today’s takeaways

Record version IDs and marker behavior.

Model current and noncurrent retention separately.

Verify all versions during teardown.

CLOSE THE LOOP

Ready to complete this day?

Verify the practical steps and pass the knowledge check (at least two thirds correct).

Lab steps verifiedKnowledge check passed