Amazon S3 Versioning: Hands-On | A Step-by-Step Guide

A step-by-step instructions on exploring Versioning in Amazon S3

Amazon S3 Versioning: Hands-On | A Step-by-Step Guide

Step 1: Navigate to Amazon S3 console

  1. Open your web browser and go to the AWS Management Console at https://console.aws.amazon.com/.

  2. Sign in to your AWS account using your credentials.

  3. Once logged in, locate and click on "S3" under the "Storage" category. This will open the Amazon S3 console.

Step 2: Create S3 Bucket and host Static website

  1. Ensure you have created your S3 bucket. If not, follow the steps outlined in the "AWS S3 Console Hands-On | A Step-by-Step Guide" tutorial available at: S3 Console Hands-On | A Step-by-Step Guide

  2. For Testing It would be great if you create a static website. You can follow the steps outlined in the Amazon S3 Static Website Hosting: Hands-On | A Step-by-Step Guide

  3. Your Static Website looks like below

  1. You can see the updates

Step 3: Enable Bucket Versioning

  1. Navigate to your S3 bucket properties.

  2. Find the "Bucket versioning" setting and edit it.

  3. Enable versioning to allow the creation of multiple versions of files.

Step 4: Update Website Content

  1. Locate the website URL and access the file you want to update (e.g., index.html).

    We created this file in Step 4 while creating Static website

  2. Edit the file content as desired (e.g., change src="mountain.jpg" to src="tree.jpg").

     <!Same as existing code>
         <div class="column">
           <h3>from current directory src="Tree.jpg" </h3>
           <img class="image" src="Tree.jpg" alt="Mountain from current directory">
         </div>
     <!Same as existing code>
    
  3. Save the changes and re-upload the file to the bucket same as Step 5: Upload Index HTML File.

Step 5: Test the updated websites

  1. Scroll down to the "Properties" section again and find the "Static website hosting" option.

  2. Copy the bucket website endpoint URL provided.

  3. Paste the bucket website endpoint URL into your browser's address bar and navigate to it.

Step 6: View File Versions

  1. Enable the "Show versions" toggle to display version IDs for files.

  2. Notice that files uploaded before versioning was enabled have a null version ID.

  3. Newly uploaded files have unique version IDs.

Step 7: Rollback to Previous Version

  1. Select the specific version ID you want to rollback to (e.g., the version with "I love coffee").

  2. Permanently delete the current version to revert to the selected version.

  3. Confirm the deletion by typing "permanently delete" and clicking "delete objects."

  4. Test the Updates in the Static Website which is restored to original state

Step 8: Handle Delete Markers

  1. Disable the "Show versions" toggle to hide version IDs and Delete an object

  2. Delete an object by adding a delete marker, Type "delete" and click delete.

  3. It is Now not visible in the buckets

  4. However, It hides the object without permanently deleting it, and we can still see it in when we toggle "show versions"

  5. Restore the deleted object by permanently deleting the delete marker. This is same as Step 7: Rollback to Previous Version

  6. Verify changes by refreshing the bucket.

Step 8: Experiment with Versioning

  1. Explore additional features of versioning, such as adding multiple versions and deleting objects.

  2. Observe the effects of versioning on file management and website functionality.

Conclusion

  • Versioning in Amazon S3 allows for efficient file management and easy rollback of changes.

  • Experimenting with versioning features enhances your understanding of S3 capabilities and best practices.