Bucket Versioning

Introduce

  • Versioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket.

  • You can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets.

  • With versioning you can recover more easily from both unintended user actions and application failures, Versioning-enabled buckets can help you recover objects from accidental deletion or overwrite

  • After versioning is enabled for a bucket, if Amazon S3 receives multiple write requests for the same object simultaneously, it stores all of those objects.

  1. Enable Bucket Versioning feature

    • In the S3 bucket interface, select bucket name aws-first-cloud-journey

    • Select Properties, in Bucket Versioning, select Edit

    Static website

    • In the Bucket Versioning section, select Enable, select Save changes

    Static website

  2. Change the content on the file index.html

    • Open the window containing the folders, files downloaded and extracted in lab 2.2

    • Select file index.html -> right click -> select Open with -> select Notepad

    Static website

    • Scroll down to the middle of the page, at tag body, replace the value AWS First Cloud Journey with something else, for example: LEARNING CLOUD ^^ LEARNING FUN <3

    • Before editing:

    Static website

    • After editing:

    Static website

    • Press the key combination: Ctrl and S to save the edited content in the index.html file
  3. Test versioning feature on S3

    • At the S3 bucket interface AWS First Cloud Journey, select Upload

    • Upload the newly edited index.html file into the AWS First Cloud Journey bucket by dragging and dropping

    Static website

    • At the Upload interface, index.html file in the Files and folders section, scroll to the bottom of the page and select Upload

    Static website

    • The upload file has been completed, select Close to return to the bucket interface

    Static website

    • In the search box, type index.html and press enter. You will see that the bucket only displays one object. Move the circle button of Show versions from left to right to see the version of the file.

    Static website

    • Now you see there are 2 index.html files, with the modification time of the object above being closer to the current time than the object below

    Static website

  4. Test versioning feature on Cloudfront

    • In step 7.3 Check Amazon CloudFront, you accelerated your website with Cloudfront and performed a Distribution domain name check with content content: AWS FIRST CLOUD JOURNEY

    Static website

    • So let’s see if the Default root object with the file index.html has just been uploaded to a lasted version on S3, will the content change corresponding to step 2 above?

    • Open the Amazon CloudFront console at https://console.aws.amazon.com/cloudfront/home

    • Select current Distributions ID

    Static website

    • Select Behaviors, select the check mark, select Edit

    Static website

    • At Cache key and origin requests, select Legacy cache settings
    • In the Object caching section, select Customize
    • In the Maximum TTL section, enter the new value: 1
    • In the Default TTL section, enter the new value: 1
    • Scroll to the bottom of the page, select Save changes
    • -> This will help Cloudfront regularly update changes from S3 within the framework of this lab

    Static website

    • You need to wait a few minutes for the status to change from Deploying to the time of last modification

    Static website

    Static website

    • Then, copy the Domain name into the browser to see the changed content

    Static website

    • However, at this time, if you want to quickly restore the old content without having to edit the index.html file on your local machine - just delete the latest version object: index.html on S3 bucket

    • In the S3 bucket console aws-first-cloud-journey, in the search box - type index.html then enter, select Show versions.

    Static website

    • Check the box symbol at the top of the index.html object, select Delete

    Static website

    • Check the correct file to delete -> enter permanently delete in the box -> select Delete objects

    Static website

    • At the browser page running CloudFront’s Domain name, press the F5 key to refresh the page, you will receive the old value: AWS FIRST CLOUD JOURNEY

    Static website