S3 Object Versioning is one of the best features in Amazon S3. Object versioning is used to avoid the overwrite and deletion. Versioning is not enabled by default and this feature is used to keep multiple versions of objects at the same time in the bucket.
If we are enable the versioning on the bucket, we can't delete an object directly. All versions remain in the bucket and a delete marker is introduced which becomes the current version. So if you need to delete an object, you need to remove that delete marker also. Existing objects in your bucket do not change and only future requests behavior changes. If we put an object retrieval request, the current version of the object will always return.
After Versioning Enabled
Three states of Buckets:
Unversioned (default)
Versioning-enabled
Versioning-suspended
Now we are going to discuss how to enable versioning.
Log in to the AWS Management Console and type “S3” in the search box.
You will see an S3 dashboard, click create buckets.
The next step is to select the Region that is closest to you and enter the name of your bucket.
Click on the Create Bucket button, leave all the settings the way they are, and scroll down.
It is important to remember that a bucket’s name should always be unique and should not already exist publicly under a similar name; otherwise, your bucket will not be created.
We have created our first bucket, click on the name of the bucket to open it.
Here is a list of many of the features like Objects, Property, Permissions, Metrics, and others.
Now, let us upload our first object into our bucket in S3.
Open your browser and save a . Jpg image or file on your local computer.
Click on Upload.
Click on Add files.
Choose a file in the .txt format
Click on Add files & upload again same file some updated content .
See what happend.. when you upload same name of file automatically deleted existing one... here overriding is there... so we can enable the versioning.
You can now view the bucket’s properties by clicking on it.
Click Edit button in the Versioning .
Once Enable is clicked, click Save changes.
There is now a new option called Show versions that can be enabled.
There will be a new column Version ID which will display the object name but the version id will be null, meaning the file was uploaded to the bucket before versioning was enabled.
To explore more we are going to upload new files.
Go back to your bucket page.
select upload files & upload the same file with updated one.
As we can see, the newly uploaded file contains a Version ID.
So to get a Version ID you must enable versioning before you upload any file.
Therefore, we will reupload the previous file and enable the Show versions option.
We can see that now it has 2 version IDs.
Each time we upload a file, the version ID is defined.
Try to delete the previously uploaded file now by disabling Show Versions.
Select the file and click Delete Objects.
It will display a warning as shown below.
Let’s take a closer look at what is going on, as we are not doing actual deletion. Instead, we are adding delete markers.
Click on Delete
That file has been deleted, but if you enable the Show versions option, you will see it still exists with its own version number.
The file appears to be gone, but actually, it hasn’t been deleted.
You can delete any delete marker file permanently by selecting that file as the delete marker.
Click on Delete objects and it will be deleted permanently.
Go back to the bucket page and enable Show versions
You will see that files are deleted. This allows us to restore things.
Versioning-suspended :
After perform the enable versioning operation & after perform the suspend the operation.. above shown
After suspend the versioning now versioning is disabled... now we are upload the files it will going to normal.
MFA delete we can perform via CLI or SDK..
Liked This Article?
Conclusion:
S3 Object Versioning is one of the best features in Amazon S3. Object versioning is used to avoid the overwrite and deletion. Versioning is not enabled by default and this feature is used to keep multiple versions of objects at the same time in the bucket.