S3 Object Versioning

Learn how to protect against accidental deletions using versioning to files in our S3 bucket.

Versioning is a practice in software development and data management that involves assigning unique identifiers or labels to different versions of a piece of software, a file, or a dataset. This enables tracking changes over time, maintaining a history of modifications, and facilitating collaboration among multiple contributors.

In Amazon S3, versioning enables the storage of multiple versions of an object in a bucket. This helps protect against accidental deletions or overwrites, and it can restore previous versions.

Enabling versioning on buckets

By default, versioning is disabled in S3 buckets. We can enable the versioning while creating a bucket. Also, we can enable or disable the versioning of an existing bucket. Therefore, a bucket can be in one of the three states:

  • Unversioned: The versioning is disabled while creating the bucket.

  • Versioning-enabled: We can enable the versioning of a bucket while creating it or modify it later on. If we enable versioning of a nonempty bucket, the S3 bucket assigns an ID of null to all the existing objects. It then assigns numeric version IDs to any new objects.

  • Versioning-suspended: We can also disable the versioning of a versioning-enabled bucket. If we decide to suspend the versioning of a bucket, it does not change the version ID of existing objects and only handles the newly added objects differently. Since space is consumed by all the versions of an object in the bucket, S3 charges for every version of the object in the bucket. When we suspend the versioning in a bucket, S3 charges for the previously stored versions of the objects. To minimize the costs in such a scenario, create another S3 bucket and upload all the current versions or manually delete the previous versions.

Get hands-on with 1400+ tech skills courses.