0
0
AWScloud~10 mins

S3 versioning in AWS - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - S3 versioning
Create S3 Bucket
Enable Versioning
Upload Object v1
Upload Object v2 (same key)
Store multiple versions
Retrieve or Delete specific version
This flow shows creating a bucket, enabling versioning, uploading objects with the same name to create versions, and managing those versions.
Execution Sample
AWS
aws s3api create-bucket --bucket my-bucket --region us-east-1
aws s3api put-bucket-versioning --bucket my-bucket --versioning-configuration Status=Enabled
aws s3api put-object --bucket my-bucket --key file.txt --body file_v1.txt
aws s3api put-object --bucket my-bucket --key file.txt --body file_v2.txt
This code creates a bucket, enables versioning, then uploads two versions of the same file.
Process Table
StepActionBucket Versioning StatusObject KeyVersion ID CreatedNotes
1Create bucket 'my-bucket'Disabled (default)--Bucket created without versioning
2Enable versioning on 'my-bucket'Enabled--Versioning turned on
3Upload 'file.txt' with content v1Enabledfile.txtv1-id-123First version stored
4Upload 'file.txt' with content v2Enabledfile.txtv2-id-456Second version stored, old version kept
5Retrieve 'file.txt' without version IDEnabledfile.txtv2-id-456Latest version returned
6Retrieve 'file.txt' with version ID 'v1-id-123'Enabledfile.txtv1-id-123First version returned
7Delete 'file.txt' without version IDEnabledfile.txtDelete Marker IDDelete marker added, object hidden but versions kept
8Delete 'file.txt' with version ID 'v1-id-123'Enabledfile.txtv1-id-123Specific version deleted, others remain
💡 Versioning keeps all versions; delete without version ID adds delete marker; delete with version ID removes that version only.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 7Final
Bucket Versioning StatusDisabledEnabledEnabledEnabledEnabledEnabled
file.txt VersionsNoneNonev1-id-123v1-id-123, v2-id-456v1-id-123, v2-id-456 + Delete Markerv2-id-456 + Delete Marker
Latest Version IDNoneNonev1-id-123v2-id-456Delete MarkerDelete Marker
Key Moments - 3 Insights
Why does deleting an object without a version ID not remove all versions?
Because with versioning enabled, deleting without specifying a version adds a delete marker (see step 7), hiding the object but keeping all versions intact.
How can you retrieve an older version of an object?
By specifying the version ID when retrieving the object (see step 6), you get that exact version instead of the latest.
What happens if you upload a file with the same key after enabling versioning?
A new version is created and stored alongside previous versions (see step 4), so no data is lost.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the bucket versioning status after step 3?
AEnabled
BDisabled
CSuspended
DNot set
💡 Hint
Check the 'Bucket Versioning Status' column at step 3 in the execution table.
At which step is the delete marker added to the object versions?
AStep 4
BStep 8
CStep 7
DStep 6
💡 Hint
Look for the note mentioning 'Delete Marker' in the execution table.
If versioning was not enabled, what would happen when uploading the second 'file.txt'?
ABoth versions would be stored separately
BThe second upload would overwrite the first without keeping versions
CAn error would occur
DA delete marker would be added
💡 Hint
Refer to the concept flow and the importance of enabling versioning before uploading multiple versions.
Concept Snapshot
S3 Versioning:
- Enable versioning on a bucket to keep multiple versions of objects.
- Uploading an object with the same key creates a new version.
- Deleting without version ID adds a delete marker, hiding the object.
- Retrieve or delete specific versions by specifying version IDs.
- Versioning protects data from accidental overwrites or deletions.
Full Transcript
This visual execution shows how S3 versioning works step-by-step. First, a bucket is created without versioning. Then versioning is enabled. Uploading a file creates a version. Uploading again with the same name creates a new version, keeping the old one. Retrieving without version ID gets the latest version. Retrieving with version ID gets that specific version. Deleting without version ID adds a delete marker, hiding the object but keeping versions. Deleting with version ID removes that version only. This protects data from accidental loss.