Edit Template

Enabling Versioning in Amazon S3: A Step-by-Step Guide

Introduction:

Amazon Simple Storage Service (S3) is one of the most versatile and widely used storage solutions in the cloud. One of its standout features is versioning, which allows you to preserve, retrieve, and restore every version of every object stored in your bucket. This feature is particularly useful for data protection, accidental deletion recovery, and auditing purposes.

In this blog, we will explore how to enable versioning in an Amazon S3 bucket, its benefits, use cases, and step-by-step instructions.

What Is S3 Bucket Versioning?

Amazon S3 bucket versioning is a feature that keeps multiple versions of an object within the same bucket. When you modify or delete an object in a versioned bucket, S3 retains the previous versions of the object, making it possible to recover or restore older versions when needed.

Key Features of Versioning:

  1. Retain previous versions of objects.
  2. Recover accidentally deleted or overwritten objects.
  3. Enable lifecycle management for versioned objects.
  4. Support cross-region replication (CRR) with versioning enabled on both source and destination buckets.

Benefits of S3 Versioning

  1. Data Protection: Protects data from accidental overwrites or deletions.
  2. Compliance: Meets regulatory requirements by retaining object versions for auditing purposes.
  3. Disaster Recovery: Enables recovery from application failures or human errors.
  4. Audit Trail: Maintains a history of changes made to objects.

Step by Step procedure for enabling versioning in S3

Step1: Create an S3 Bucket

  1. Navigate to the Services menu at the top and click on S3 in the Storage section.
  2. On the S3 dashboard, click on the Create bucket button and fill in the bucket details.
  3. Select Region as N.Virginia to create an S3 bucket.
  • Bucket type Select : General purpose
  • Bucket name: Enter devopshorizon

4. Object ownership: Select ACLs disabled (recommended) option.

5. Uncheck the option, Block all public access, and check the acknowledge option.

6. Leave other settings as default.

7. Click on the Create bucket button.

Step2: Enable Versioning on the S3 bucket

  1. Click on your bucket name devopshorizon.
  2. Click on the Properties tab.
  3. Under Bucket Versioning, click on the Edit button.
  4. Bucket Versioning : Select Enable radio button.

5. Now Click on the Save changes button.

6. Now Bucket versioning is enabled.

Step3: Upload an object and make the bucket public

  1. Click on the Objects tab.
  2. To upload a file to our S3 bucket,
  • Click on the Upload button.
  • Click on the Add files button.
  • Browse for the file you want to upload.
  • Click on the Upload button.

3. Now click on the Close button on the top right corner of the screen.
4. To copy the ARN of your S3 bucket, click on the Properties tab and copy the ARN.
5. Make the bucket public with a Bucket Policy:

  1. Click the Permissions tab to configure your bucket:
  2. Scroll down to Bucket policy , click on Edit button on the Right side.
  3. The policy editor will open.
  4. In the policy below, update your bucket ARN in the Resource key-value and copy the policy code. 
  5. Paste the bucket policy into the Bucket policy editor.

{

    “Id”: “Policy1”,

    “Version”: “2012-10-17”,

    “Statement”: [

        {

            “Sid”: “Stmt1”,

            “Action”: [

                “s3:GetObject”

            ],

            “Effect”: “Allow”,

            “Resource”: “replace-this-string-from-your-bucket-arn/*”,

            “Principal”: “*”

        }

    ]

}

6. Click on Save Changes button
7. Now again open the Objects tab, select the object name and click on Copy URL.

8. Open a new tab, paste the URL and you will get the below output.

Step4: Upload different versions of the file

  1. Now open the text.txt file in your local text editor and update the file content as “This is DevopsHorizon version 2”.
  2. Click on the Upload button.
  3. Click on the Add files button.
  4. Browse for the file you want to upload.
  5. Click on the Upload button.
  6. Now click on the Close button on the top right corner of the screen.
  7. Once the file has been uploaded successfully, copy the URL and paste it into your browser.
  8. You should see the latest version of the file you uploaded.

Step5: See the Versioning of the object

  1. Open your S3 bucket, click on Show versions. You will get the list of versions available for your text.txt.

Use Cases for Versioning

  1. Application Backups: Automatically maintain historical versions of configuration files or datasets.
  2. Audit Logs: Store multiple versions of logs for compliance and debugging.
  3. Disaster Recovery: Restore objects to previous states after data corruption or deletion.
  4. Collaboration: Track changes in collaborative environments where multiple users interact with the same data.

Conclusion

Enabling versioning in Amazon S3 is a simple yet powerful way to protect your data, support compliance, and enhance disaster recovery. By following the steps outlined above, you can activate this feature through various methods, including the console, CLI, SDKs, and automation tools. While versioning adds robust capabilities, it is essential to manage storage costs and configure lifecycle policies to maintain efficiency. With versioning enabled, you can confidently safeguard your critical data and ensure uninterrupted access to previous versions whenever required. Follow DevopsHorizon for more blogs on Cloud and DevOps.

Leave a Reply

Your email address will not be published. Required fields are marked *

Most Recent Posts

Category

content created for you!

Company

About Us

FAQs

Contact Us

Terms & Conditions

Features

Copyright Notice

Mailing List

Social Media Links

Help Center

Products

Sitemap

New Releases

Best Sellers

Newsletter

Help

Copyright

Mailing List

© 2023 DevOps Horizon