S3 Versioning is a feature that allows you to keep multiple versions of an object in the same bucket, protecting against accidental deletion or overwrite by preserving, retrieving, and restoring every version of every object stored in your buckets.
Amazon S3 Versioning is a powerful data protection feature that maintains multiple variants of an object within the same bucket . When enabled, S3 automatically assigns a unique version ID to each object uploaded to the bucket . This means that if you modify or overwrite an object, instead of replacing the existing object, S3 creates a new version while preserving all previous versions . This allows you to easily recover from accidental user actions, application failures, or unintended overwrites .
Default state: Versioning is disabled by default on all new buckets and must be explicitly enabled
Bucket-level setting: Versioning is enabled or suspended at the bucket level and applies to all objects in the bucket
Three bucket states: Buckets can be unversioned (default), versioning-enabled, or versioning-suspended
Permanent change: Once a bucket is versioning-enabled, it can never return to an unversioned state - it can only be suspended
Pre-existing objects: Objects stored before versioning was enabled have a version ID of 'null'
Delete markers: When you delete an object in a versioned bucket, S3 doesn't permanently remove the object. Instead, it inserts a delete marker, which becomes the current version
Object appearance: The object appears deleted when you list objects normally, but all previous versions remain accessible
Restoring objects: To restore a deleted object, you simply remove the delete marker, which restores the previous version as the current version
Each version of an object is stored as a complete object, not just a diff of changes, meaning storage costs apply to each version individually . For example, if you have three versions of a 1GB object stored, you are billed for 3GB of storage. To manage these costs effectively, it's recommended to combine versioning with S3 Lifecycle policies to automatically transition older versions to lower-cost storage classes or expire them when no longer needed . Lifecycle rules can manage current and previous versions separately—for example, moving previous versions to Glacier after 30 days and permanently deleting them after 365 days .
Enable versioning early: You cannot retroactively recover versions created before versioning was enabled
Combine with lifecycle rules: Use lifecycle policies to manage storage costs by transitioning or expiring old versions
Monitor bucket growth: Versioned buckets can grow rapidly—use cost analysis tools to track storage usage over time
Update lifecycle rules for versioned buckets: If you had expiration policies before enabling versioning, add noncurrent version expiration rules to maintain the same behavior