Skip to main content
In this lesson we explain Amazon S3 versioning: the problems it solves, how it behaves, and the practical effects on deletes, storage costs, and security. Why use S3 versioning?
  • Without versioning (the default), each S3 object key maps to a single object. Uploading a new object with the same key or deleting an object permanently removes the previous content.
  • Versioning protects against accidental deletions and overwrites by preserving prior object versions so you can retrieve or restore them later.
Use cases:
  • Recover from accidental overwrites or deletions.
  • Maintain an audit trail of object changes.
  • Support application workflows that require historic object states.
Bucket-level configuration and states Versioning is a bucket-level feature. A bucket can be in one of three states: Important: once you enable versioning on a bucket you cannot return it to an unversioned state; you can only suspend versioning. Suspending does not delete or consolidate existing versions. How versioning works When versioning is enabled, each object upload receives a unique version ID (a long opaque string). Multiple uploads for the same key create multiple versions instead of overwriting the previous one. The newest version is called the latest (or current) version and is returned when you request the object without specifying a version ID.
A presentation slide titled "How Versioning Works" showing three stacked boxes for the same key (file1.txt) with Version-ID 1, 2, and 3 and a "Latest Version" label on the top box. Accompanying text explains that uploading a file with the same key gives it a newer version ID and the newest version is what users see.
The S3 console and API list every stored version for a key with its version ID and timestamps. When versioning is disabled, objects have a null version ID. Delete behavior and delete markers With versioning enabled, a delete operation that does not specify a version ID does not remove prior versions. Instead, S3 creates a special version called a delete marker. The delete marker becomes the latest version and makes the object appear deleted when requested without a version ID. The prior non-marker versions remain and can be restored by removing the delete marker (deleting that version). If you delete a specific version by providing its version ID, that specific version is permanently removed (unless restored via backups outside S3). Deleting the delete marker itself restores the previous latest non-marker version to visibility.
Delete markers are themselves versions. Removing a delete marker (by deleting that version) restores the previous non-marker version as the latest visible object.
A presentation slide titled "Deleting File Versions" showing a "Delete Marker" next to two stacked file version boxes labeled "Key: file1.txt" with Version-ID 2 and Version-ID 1.
Storage and pricing implications When versioning is enabled, you are billed for each stored version of an object. For example, if file1.txt has two stored versions of 10 GB and 15 GB, your storage billing will reflect 25 GB. Keep these cost drivers in mind:
  • Frequent updates to large objects produce many versions.
  • Delete markers incur minimal storage, but previous full versions remain charged.
  • Use lifecycle policies to transition or expire older versions to control costs.
A slide titled "Versioning Pricing" showing two blue rounded boxes representing versions of file1.txt. The boxes list Version-ID 2 (Size: 15 GB) and Version-ID 1 (Size: 10 GB).
Suspending versioning Suspending versioning preserves all existing versions; S3 does not remove or merge them. New objects uploaded while suspended receive a null version ID (same as an unversioned bucket). Later re-enabling versioning causes new uploads to again receive unique version IDs. Note: uploading an object with a null version ID will overwrite any existing null version for that key, but earlier non-null versions remain preserved and retrievable by version ID.
A slide titled "Version Suspending" comparing "Versioning Enabled" and "Suspended Versioning." It shows stacked blue boxes for keys like file1.txt and house.png with Version-ID values (3, 2, 1) and NULL markers to illustrate how versions are stored.
MFA Delete MFA Delete is an extra protection that ties sensitive operations to multi-factor authentication. With MFA Delete enabled:
  • Changing the bucket’s versioning state (enable/suspend) requires MFA.
  • Deleting specific object versions or removing delete markers requires MFA.
MFA Delete can only be enabled via the AWS CLI or API and historically required account-level credentials (e.g., the root account). Example CLI commands: Enable versioning (standard):
Enable versioning with MFA Delete (example — requires proper account credentials and MFA token):
Because MFA Delete has specific account and permission requirements, consult AWS documentation for exact prerequisites and syntax for your environment:
A presentation slide titled "Multi-Factor Authentication (MFA) Delete" explaining that when enabled MFA is required to change a bucket's versioning state and to delete object versions (MFA can only be enabled via CLI). The slide includes simple icons of a checkmark and a storage bucket.
Best practices and lifecycle management
  • Plan versioning before enabling it—once enabled you cannot revert to unversioned.
  • Combine versioning with lifecycle rules to transition older versions to cheaper storage classes or to expire unwanted versions.
  • Use object lock or backups for additional immutability and retention guarantees where required.
  • Monitor storage growth and tagging patterns to manage costs and governance.
Summary
  • Versioning preserves every version of an object in a bucket, enabling retrieval and restoration of prior states.
  • Versioning is disabled by default and must be enabled at the bucket level.
  • Buckets have three states: unversioned (disabled), enabled, and suspended.
  • Once enabled you cannot return to an unversioned state; you can only suspend versioning. Suspending keeps existing versions but stops generating new version IDs.
  • You are charged for every stored version—costs can accumulate without lifecycle policies.
  • MFA Delete adds an extra layer of protection for changing versioning state and deleting versions; it must be enabled via CLI/API with appropriate account privileges.
A presentation slide titled "Summary" showing four numbered points about bucket/object versioning (what it does, that it’s disabled by default, must be enabled at the bucket level, and has three states). A turquoise gradient panel is on the left with a small "© Copyright KodeKloud" notice.
A presentation slide titled "Summary" with a turquoise left panel and numbered bullets on the right. The bullets summarize bucket versioning: once enabled it can't be fully reverted, suspended state keeps old versions but stops new ones, users are charged per version, and MFA can secure versioning.
Additional resources
Be sure to plan versioning and lifecycle policies (such as object expiration or version cleanup) before enabling versioning, because once enabled it cannot be undone and you will be billed for all stored versions.

Watch Video