This article will discuss the S3 versioning feature, which is a data protection feature in Amazon S3.

These topics will be covered:

  • Concepts of S3 versioning
  • S3 versioning enabling and objects manipulation
  • S3 versioning suspending and objects manipulation

You can read more about Amazon S3 service in this article Amazon AWS – Understanding EC2 storage – Part III.

VMware Training – Resources (Intense)

So let’s start with versioning. Versioning represents a way to maintain multiple objects that have the same key, but different version IDs. As a simple example, you can have two objects with the same name, but different version IDs. Normally, without versioning, the file will be overwritten.

S3 versioning prevents objects loss from accidental deletion or overwrite (as mentioned above). If you delete an object, S3 inserts a delete marker that becomes the new version. You can restore the object to the previous version. If you overwrite the object, the new object will have a new version so you can restore to the previous version.

The versioning is enabled per bucket and a bucket can be: unversioned (versioning is not enabled and this is the default state), versioning-enabled, and versioning-suspended.

Once versioning is enabled, it cannot be disabled. It can only be suspended.

The versioning is applicable to all objects from the bucket. Once versioning is enabled, each object from the bucket is getting a version ID. The objects that were in the bucket before versioning was enabled, will receive the version ID of “null.” If versioning is suspended, then existing objects are not changed. If new objects are added to a suspended bucket, then those objects will receive the version ID of “null.”

Versioning works very well with another feature of S3 buckets and that is objects lifecycle management. We will discuss in another article about this feature and how it’s interacting with S3 versioning.

How do you enable S3 versioning?

First go to S3 Console and open the bucket for which you would like to enable versioning.

As you can see, I have one bucket containing two objects.

From the right menu, select “Properties” and then expand the “Versioning” menu. A short description of the feature is shown and you can enable versioning by clicking on “Enable Versioning”:

A final confirmation is being requested to the user and once agreed and you are done:

However, you will not see any change in regard to the objects from the bucket. This is because, by default, the versions are hidden and you have access only to the last version of the object. You need to make them visible:

Clicking on “Show” will reveal the versions of your objects, which should be “null” because they were in the bucket before we enabled versioning:

Let’s copy the file text1.txt one more time in the bucket and confirm that we now have a version ID different than “null”:

Also, notice the difference in the link name use to access the file. These are the properties of the object when I choose not to see the versions. As I said, I will see the last version of the object:

And these are the properties of the last version of the object:

This is important because you need to be able to distinguish between versions of the same object.

For instance, I have a file called file.txt which initially contained the string “1”. I uploaded the file to the bucket and received a version ID. Then I edited that file and put the string “2” and uploaded it again. Then, for the third time, I replaced the string with “3” and uploaded it again.

Basically, now I have three versions of the same object. But the versions are not identical and I can retrieve the version that suits me best:

As you can see, the newest version is “zZVb7QALOYZq7B8i8QSXxD8t7EcchuyT” and these two links will point you to the same object and content: and

Also, you can set different permissions for each version of the object. This means that someone might not be able to access the latest version of the object, but should be able to access a previous version.

We mentioned that the bucket can be in versioning-suspended state. Let’s suspend the versioning for our bucket:

Again after a confirmation, the versioning is suspended and not disabled, as you can see below:

Let’s add the same file, file.txt, but this time with the string “4”.

As mentioned before, the version for this object will be “null”:

Now the bucket is working, as the versioning is not there at all. The same file added to the bucket will overwrite the current one:

To download the object with a specific version, you need to proceed similarly as with any other objects. Just right-click on that objects and select “Download.”

From the S3 Console, you can delete any version of the object. Just select the version, right click on it and select “Delete.” Below I deleted one version of the object file.txt:

So what happens if you enable versioning, then you suspend it, enable it back, and lastly you suspend it again?

Considering the same file, file.txt, after I enabled the versioning the third time, I uploaded it again to the bucket, notice the version ID. The version “null” contains the string “5” and the version 2utpv5VrhI5zpbb2wK.n7Hf0.fnFk6L4 contains the string “6”.

Now I suspended the versioning again and uploaded again the file with the string “7”:

Seems that two “null versions are here; however, there is no way to differentiate between them. The oldest “null” version contains the string “5” and the newer one contains “7”. However, both of them have the link and when you access this link, you end up seeing the string “7”. How do you access the other version?

The answer is that you cannot access it. That version is deleted, overwritten. It, like you, added two objects with the same name while versioning was disabled or suspended:

And we pretty much tried all the operations available from AWS S3 Console on buckets that have versioning enabled or suspended.

By now you should know what S3 versioning is and how you can enable and suspend it. As said, you cannot disable it completely once has been enabled.

I hope you will find this useful next time when you will wonder how you can save the data in Amazon S3 and be able to retrieve the data that you had at one moment of time.


  1. Amazon S3 versioning
  2. Objects in a Versioning-Enabled Bucket
  3. Objects in a Versioning-Suspended Bucket