‫So let's practice replication
‫on Amazon S3.
‫For this, we're going to create a new bucket.
‫I'll call it s3-stephane-bucket-origin-v2.
‫And I will set it in one region that I want,
‫for example, eu-west-1.
‫This will be my origin bucket
‫and then data will be replicated
‫from this bucket to another bucket.
‫So the thing I need to do, of course,
‫is to enable versioning
‫because replication only works
‫if versioning is enabled.
‫So I will create this bucket.
‫And then open this bucket in a new tab.
‫And I will create a second bucket
‫and this will be my target bucket.
‫So I will do s3-stephane-bucket-replica-v2.
‫And this time, the region can be either the same,
‫for example, if you wanted to do same region replication
‫or something completely different,
‫for example, if you wanted the US,
‫you could do us-east-1
‫to replicate from Europe to the US.
‫Okay, so let's scroll down
‫and let's again enable bucket versioning
‫on the target bucket.
‫And we're good to go.
‫So now we have our primary bucket
‫and our secondary bucket.
‫What I'm going to do is that in the origin bucket,
‫I'm going to upload a file,
‫so I will add a file of my beach, for example.
‫Beach.jpg.
‫Okay, this is done and we can close this.
‫So now this has one file
‫but, of course, this does not get replicated yet
‫because we haven't set up replication yet.
‫So let's go ahead and do this.
‫So on the origin bucket,
‫what I need to do is to go under Management,
‫scroll down and there are replication rules.
‫Currently zero.
‫So let's go ahead and create our first replication rule.
‫So I'll call this one DemoReplicationRule.
‫Okay, perfect.
‫We'll set it as enabled.
‫For the source bucket, we'll leave it as is
‫and in terms of rule scope,
‫we'll apply it to all objects in the bucket.
‫Now, for the destination,
‫we can specify a bucket in this account
‫or another account.
‫And we'll choose one in this account.
‫And the bucket name is my target bucket.
‫So I need to actually enter the name.
‫So we'll take this bucket right here,
‫copy and paste it.
‫Okay, and as you can see,
‫the destination region was identified
‫as being us-east-1.
‫So therefore, this is a Cross-Region Replication.
‫Okay.
‫Now for IAM role,
‫we need to actually go and create a new role for this.
‫So here's the option.
‫And then we can have a look at some settings
‫but for now it doesn't really matter for us.
‫Let's just save this.
‫So we get a prompt right here,
‫which says do you want to replicate existing objects?
‫So it turns out that when you do enable replication,
‫it will only replicate objects
‫from the moment you set it.
‫So for newer uploads.
‫So if you wanted to replicate the previous objects
‫from the source to the destination bucket,
‫you could use something called a Batch Operation,
‫an S3 Batch Operation to do so
‫and you would need to say yes, replicate existing objects.
‫But this is separate
‫from the replication feature itself.
‫Therefore, I'm going to say no,
‫do not replicate existing objects.
‫And we're good to go.
‫So now let's have a look.
‫So we have this Management
‫with a replication rule that is ready.
‫And now what I'm going to do
‫is check in my replica bucket.
‫Of course, if I refresh now,
‫we see that the objects haven't been replicated.
‫So I'm going to do is now upload a new file,
‫for example, upload the coffee.jpg file.
‫Upload it.
‫We're done.
‫So here is the coffee.jpg file.
‫Let's show the versions.
‫So this is coffee.jpg and the version is GBk.
‫Okay, perfect.
‫Now if we go in my target bucket, and refresh this,
‫it's gonna take maybe five seconds.
‫And this took about 10 seconds on the first replication
‫but we can see that my coffee.jpg
‫has been added into my replica bucket.
‫And if I show the versions,
‫we can see that the version ID of my coffee.jpg
‫is the exact same of the origin bucket.
‫So the version's IDs are replicated,
‫which is great.
‫And if I wanted to import the beach.jpg,
‫I would need to upload a new version of that file.
‫So let's upload beach.jpg again.
‫Now this has been uploaded,
‫we can look at the versions,
‫so there is a new version right here
‫of DK2 of my beach.jpg file.
‫And now if I go here and refresh,
‫now let's look at one more setting
‫that is important for your exam.
‫So if I go back into Management,
‫and take this and edit this role,
‫we can scroll down and have a look
‫at one setting called the delete marker replication.
‫So by default, delete markers
‫are not replicated
‫but there's a feature to do so.
‫So if you enable delete marker replication,
‫then they will be replicated from one bucket to another.
‫So let's save this.
‫So my replication rules have been saved.
‫And so that means that if I go in this bucket,
‫and I choose to delete this file, for example,
‫I delete my coffee.jpg file, let's delete it.
‫This will actually create a delete marker
‫because my bucket is versioned.
‫We're done.
‫So now my coffee.jpg is deleted.
‫And let's have a look in here.
‫So let's refresh and we need to wait little bit.
‫And now you can see that the delete marker
‫has been replicated to my replica bucket.
‫So if I don't show version,
‫I don't see my coffee.jpg file
‫but of course, if I show versions, I will see it.
‫This is true here.
‫And of course, this is true here as well.
‫So the delete markers are deleted
‫but if you decide to delete a specific version
‫of a file, for example,
‫I delete this one, which is I delete a specific version ID.
‫So this is called the permanent delete.
‫And if I permanently delete one object
‫in my origin bucket,
‫it will not be replicated to my replica bucket.
‫So this beach.jpg here will never be deleted
‫because only delete markers are replicated,
‫not deletes, okay?
‫So that's it for this lecture.
‫I hope you liked it and I will see you in the next lecture.