Cost Consideration: Each version of an object is stored as a complete copy, not just differences. If you have 3 versions of a file, you pay for 3 complete files. AWS charges normal S3 rates for every version stored and transferred. Consider using lifecycle policies to manage old versions.
Versioning in Amazon S3 is a feature that allows you to keep multiple variants of an object in the same bucket. With versioning enabled, you can preserve, retrieve, and restore every version of every object stored in your bucket, providing an additional layer of data protection against accidental deletion or modification.
When versioning is enabled on a bucket:
S3 buckets can be in one of three versioning states:
Use Lifecycle Policies: Automatically delete old versions after a specified time
Monitor Costs: Versioning can significantly increase storage costs
MFA Delete: Enable MFA Delete for additional security on version deletion
Cross-Region Replication: Replicate versions across regions for disaster recovery
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.
Enable Bucket Versioning feature
In the S3 bucket interface, select bucket name aws-first-cloud-journey
Select Properties, in Bucket Versioning, select Edit
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
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:
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
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.Test versioning feature on Cloudfront
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
1
1
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.
permanently delete
in the box -> select Delete objects