-: It is possible for you to version your files in Amazon S3.
And so to do this,
you have to enable it at the bucket level.
Okay, it is not at profile setting,
it is a bucket level setting.
Basically that means that if you overwrite a file
you will increment its version.
So when you first upload a file, it is version 1.
Then when you overwrite it,
it is version 2, then version 3, etc.
And your Amazon S3 bucket
will keep all the versions in mind.
It is best practice, to be honest, to version your bucket.
Why?
Well, because you can protect yourself
against unintended deletes.
Basically you're able to restore a previous version.
And you can easily roll back to your previous version
in case there was any problem.
So this is quite best practice, to version your buckets.
The only downside is that you use a bit more
space on your Amazon S3 bucket.
Finally, any file that is not versioned
prior to enabling the versioning,
will have the version null.
And this is just something that you should know
in case they ask this at the exam.
So let's go ahead and practice this in the hands-on.
So I'm in my S3 bucket.
And I will go to properties
click on versioning, and as you can see,
I can enable versioning.
Then I click on save and it says enabled.
Then I go back to overview
and now you should be seeing
a versions hide and show type of toggle, right here.
So I'll click on show
and if you don't see this, refresh the page,
go back to your properties and refresh this.
Sometimes it takes a bit of time to enable versioning.
So you go to overview and you show the versions.
And the first thing we see is that the coffee.jpg file,
that was uploaded before we enabled versioning
has a version ID null.
So we just saw this in the lecture.
Now if I open a file, add a file
and make this file my beach.jpg, upload it.
As you can see my first beach is here
and has a version ID like this.
So I did an oversimplification
when I said version 1, 2 and 3
but you get the idea that basically your file
gets a new version every time.
So if I go ahead and re-upload the very same file,
so add a file and re-upload that beach,
basically you can see that now
the new version has a new version ID.
And it overridden the version from before.
So we can look at the timestamps
and see that this one was created at 35:59pm
and this one is 35:40pm, okay.
So we see different versions.
So we can go ahead and upload as many versions as you want.
So we can re-upload the beach.
I'll go ahead and re-upload the beach
and I'll also go ahead and upload a coffee.jpg
just see how things work.
And as we can see now, even the coffee gets a version ID.
So basically as we have versioning,
now every object version gets kept into the bucket.
If we hide the version we only see
the latest version in our UI.
But if we show the version we can see all the version IDs.
The other thing that's super interesting
is that if I delete my files
so let's go ahead and right-click and delete my file,
and I say yes, I want to delete it,
it looks like it's gone if I hide the versions.
But if I show the versions we can see
that the only thing that happened
is that there was a delete marker on that file.
And so basically I'm able to restore it if I wanted to.
So here is the download file
and I could restore it if I wanted to.
But the idea is that now that you have versioning
when you delete a file, it just puts a delete marker on it
and just creates a new version of that file for you.
So that's it for versioning.
It's all you need to know.
Just remember you create new versions
every time you upload a file.
When you delete a file it's just not really deleted.
It has a delete marker on it.
And when you enable versioning,
any file that wasn't versioned before, has the null version.
So, I hope that was helpful.
Hope that helps and I will see you in the next lecture.