What’s cool about AWS S3 Versioning?

Tram Ho

Surely everyone already knows

Amazon Simple Storage Service (Amazon S3) is an object storage service that provides scalability, data availability, security, and industry-leading performance. – According to aws

To ensure the availability of data stored on S3 such as advertising aws, this service has a lot of nice features that come with it. Including a basic feature but very dangerous – it’s Versioning.

Today, this article through a mini lab will learn about Amazon S3 – Versioning with the small goal of understanding the basic working mechanism of Amazon S3 – Versioning.

Step 1: Create and set up a bucket

  • Creating a new bucket is nothing to worry about, first of all, just enter a valid name, select a region and press create – don’t think. (The following configuration config)

For AWS S3, the default 1 bucket after it is created will be private and completely block access to it.

  • So the first thing to do (for the convenience of the demo file view) is to change the permissions setting of this bucket.

  • The next – most important thing in this lab, is to set the bucket in Versioning state . => Click on bucket Properties tab -> Click on Versioning function -> Click on Enable versioning.

Note 1: Once you have enabled the versioning function of a bucket up, you cannot disable it anymore. That can only stop – suspend it

Note 2: The versioning 1 function when enabled is applied to all objects in that bucket.

The versioning state applies to all (never some) of the objects in that bucket

=> Step 1 Done.

Step 2: Demo versioning function with a txt file

  • First, you need to create a .txt file to demo this versioning function and then upload it to the bucket.

=> Just upload the config to calculate later.

  • After uploading, the uploaded file will create a url to access. However

Like the bucket, by default a file is uploaded to the public state (even though its bucket is public).

So when I finally clicked on the url of the file to see the contents of the demo file, I still got the Access Denied error

=> Click file -> Select Actions -> Click Make pulic to view file from internet

Please try again the url of the file => Delicious.

  • Now to the main part. Try to change the content of the txt file you created and upload again (of course keep the file name so that bucket understands that you are uploading the same file)

=> Same as the first time, just press upload, configure something later.

  • After uploading a new version, if the versions are set to Hide mode, nothing has changed much (time modified, yes). But when clicking on the show, you can see 2 versions with different Version IDs displayed. In addition, the newly uploaded version will be set as Lastest Version

  • Try reloading the previous url to see if the content file has been changed … => Access Denied again

Unfortunately, every time you upload a file, the bucket still defaults to the file being private (even if it is an updated new version of the file). So it is best to upload and enlist the public setting for the file to stay healthy as well.

=> Redo: Click on file -> Select Actions -> Click on Make pulic

Go to try the file’s url 1 again => Delicious times 2. The content of the file has also been changed to the latest version

=> Step 2 Done

Step 3: Now delete the (object) file, why?

  • Now try to delete the uploaded file => Click on the file -> Select Actions -> Click Delete -> Confirm

As a result, after deleting the file, it seems that the file is no longer available …

But if Turn on Versions = Show …

Deleting a file (object) while versioning is enabled only corresponds to creating a new version of the object and marked as (Delete marker). Previous versions remain the same and can be restored at any time.

  • Try clicking on the second version, we can see that this object still has the url to access as usual, only this url will be assigned the version id.

=> Click to try this url -> Still able to view the content of the file as usual

  • So now if you want to restore the state before delete, simply delete the version (Delete marker) is okay.

  • As expected, after the delete version (Delete marker) goes, everything returns to the way it was before the delete.

=> Step 3 Done


  • After a light demo as above, perhaps looking at the image below can understand the S3 versioning is like.

  • With such advantages, there will be many use cases so that we can consider using S3 Versioning in practical applications.

Thank you very much for reading.

Share the news now

Source : Viblo