‫So now let's play with S3 versioning.
‫And so first you need to go into the properties
‫and then we have a bucket versioning setting.
‫We're going to edit this and we're going to enable it.
‫And this is to enable bucket versioning.
‫And therefore any files we override now
‫is just going to add versions into our buckets.
‫So this is good.
‫Let's go into our objects
‫and say we want to update our website.
‫So let's go back, find the website URL.
‫It is right here.
‫Okay, so we have "I love coffee"
‫but let's say we want to write, "I really love coffee"
‫so therefore let's go back into here, our file.
‫And I'm going to edit it
‫and say I really love coffee.
‫I've saved it.
‫And now I upload this file again.
‫So I'm going to add a file and it will be my index.html.
‫And now we have updated content in that file.
‫So if I upload it.
‫It's successful.
‫So now it's been overwritten.
‫If I go into my first webpage and refresh this,
‫I get "I REALLY love coffee."
‫But what did happen in the back?
‫Well, if we go here
‫and we have here this toggle "Show versions"
‫we're going to show the actual version ID with the files.
‫And so we can notice a few things.
‫Number one, the files that we had uploaded before
‫such as the beach.jpg and the coffee.jpg
‫have a null version id.
‫That's because they were uploaded
‫before we had enabled versioning.
‫But this file index.html as you can see has two versions.
‫One has version ID null, which is the file we had uploaded
‫before enabling versioning.
‫But the file we uploaded just right now has a version ID.
‫And therefore, by updating this file
‫and uploading it into our S3 bucket,
‫we have created a new version ID.
‫So this is something you can only see if you
‫enable this toggle.
‫So now thanks to versioning
‫what we can do is we can actually roll-back our page.
‫So we have, "I REALLY love coffee"
‫but we wanna go back to "I love coffee."
‫So how do we do this while we click on
‫this specific version ID
‫Okay, so make sure that "Show versions" is enabled
‫and then we're going to delete.
‫And here we have to delete a specific version ID
‫of our object.
‫And therefore when we delete a specific version ID
‫of our object, it's called a permanent delete.
‫So it's a destructive operation, it cannot be undone.
‫And so if we're sure, we type permanently delete
‫in this text box and click on delete objects.
‫And now if you go back, as we can see,
‫we are back with the previous date of our bucket.
‫And therefore if I refresh this page,
‫I just get "I love coffee."
‫But what if we disable "Show versions"?
‫So now we just have our objects
‫and I'm going to take this coffee.jpg file,
‫and I will delete it itself.
‫So this time we don't actually delete
‫the underlying version ID,
‫we delete by adding a delete marker.
‫And so it doesn't actually delete the underlying object
‫as we'll see.
‫Let's just type delete this time.
‫It's not permanently delete, it's just delete
‫and we delete the object.
‫Perfect.
‫So now if we have a look at it from within our bucket,
‫it looks like the coffee.jpg file is done.
‫But if we click on "Show versions"
‫we see that we have a delete marker on our coffee.jpg file
‫with this version ID.
‫And the real, the previous, at least, coffee.jpg file
‫is still in our buckets
‫but it's being overwritten at least right now
‫from a version perspective by a delete marker.
‫So back into our webpage, if I refresh this page
‫and I refresh it by forcing a refresh,
‫by doing a Command + Shift + R to force a refresh
‫then we see that the image is not available.
‫So how do we get back this image?
‫And if I just try to, for example,
‫open this image in the new tab, it doesn't work.
‫I get a "404 Not Found."
‫So instead to get back the previous objects
‫I can click on this delete marker
‫and I'm going to delete the delete marker.
‫So I will permanently delete this delete marker.
‫And the effect of that is that it will restore
‫the previous version of my object
‫which is this one from before.
‫So back into my webpage, if I refresh it now
‫we can see that the coffee.jpg file is there.
‫So you can play around with versioning
‫you can add as many file version as you want.
‫You can start deleting them and view what happens.
‫But I hope you like this lecture
‫and I will see you in the next lecture.