1 00:00:00,330 --> 00:00:01,890 So let's practice replication 2 00:00:01,890 --> 00:00:03,420 on Amazon S3. 3 00:00:03,420 --> 00:00:05,730 For this, we're going to create a new bucket. 4 00:00:05,730 --> 00:00:10,730 I'll call it s3-stephane-bucket-origin-v2. 5 00:00:11,790 --> 00:00:13,890 And I will set it in one region that I want, 6 00:00:13,890 --> 00:00:15,720 for example, eu-west-1. 7 00:00:15,720 --> 00:00:17,040 This will be my origin bucket 8 00:00:17,040 --> 00:00:18,390 and then data will be replicated 9 00:00:18,390 --> 00:00:20,880 from this bucket to another bucket. 10 00:00:20,880 --> 00:00:22,770 So the thing I need to do, of course, 11 00:00:22,770 --> 00:00:24,150 is to enable versioning 12 00:00:24,150 --> 00:00:25,920 because replication only works 13 00:00:25,920 --> 00:00:27,693 if versioning is enabled. 14 00:00:27,693 --> 00:00:29,463 So I will create this bucket. 15 00:00:31,740 --> 00:00:34,264 And then open this bucket in a new tab. 16 00:00:34,264 --> 00:00:36,330 And I will create a second bucket 17 00:00:36,330 --> 00:00:38,580 and this will be my target bucket. 18 00:00:38,580 --> 00:00:43,453 So I will do s3-stephane-bucket-replica-v2. 19 00:00:46,500 --> 00:00:48,720 And this time, the region can be either the same, 20 00:00:48,720 --> 00:00:51,870 for example, if you wanted to do same region replication 21 00:00:51,870 --> 00:00:53,190 or something completely different, 22 00:00:53,190 --> 00:00:54,870 for example, if you wanted the US, 23 00:00:54,870 --> 00:00:57,750 you could do us-east-1 24 00:00:57,750 --> 00:01:00,990 to replicate from Europe to the US. 25 00:01:00,990 --> 00:01:02,190 Okay, so let's scroll down 26 00:01:02,190 --> 00:01:03,930 and let's again enable bucket versioning 27 00:01:03,930 --> 00:01:05,163 on the target bucket. 28 00:01:08,370 --> 00:01:09,390 And we're good to go. 29 00:01:09,390 --> 00:01:11,280 So now we have our primary bucket 30 00:01:11,280 --> 00:01:13,140 and our secondary bucket. 31 00:01:13,140 --> 00:01:15,030 What I'm going to do is that in the origin bucket, 32 00:01:15,030 --> 00:01:16,380 I'm going to upload a file, 33 00:01:16,380 --> 00:01:19,860 so I will add a file of my beach, for example. 34 00:01:19,860 --> 00:01:21,063 Beach.jpg. 35 00:01:22,710 --> 00:01:24,900 Okay, this is done and we can close this. 36 00:01:24,900 --> 00:01:25,950 So now this has one file 37 00:01:25,950 --> 00:01:28,230 but, of course, this does not get replicated yet 38 00:01:28,230 --> 00:01:30,210 because we haven't set up replication yet. 39 00:01:30,210 --> 00:01:32,010 So let's go ahead and do this. 40 00:01:32,010 --> 00:01:33,960 So on the origin bucket, 41 00:01:33,960 --> 00:01:37,350 what I need to do is to go under Management, 42 00:01:37,350 --> 00:01:39,660 scroll down and there are replication rules. 43 00:01:39,660 --> 00:01:40,800 Currently zero. 44 00:01:40,800 --> 00:01:44,760 So let's go ahead and create our first replication rule. 45 00:01:44,760 --> 00:01:47,300 So I'll call this one DemoReplicationRule. 46 00:01:48,480 --> 00:01:49,680 Okay, perfect. 47 00:01:49,680 --> 00:01:51,420 We'll set it as enabled. 48 00:01:51,420 --> 00:01:53,730 For the source bucket, we'll leave it as is 49 00:01:53,730 --> 00:01:55,500 and in terms of rule scope, 50 00:01:55,500 --> 00:01:58,830 we'll apply it to all objects in the bucket. 51 00:01:58,830 --> 00:02:00,240 Now, for the destination, 52 00:02:00,240 --> 00:02:02,820 we can specify a bucket in this account 53 00:02:02,820 --> 00:02:04,350 or another account. 54 00:02:04,350 --> 00:02:06,005 And we'll choose one in this account. 55 00:02:06,005 --> 00:02:10,860 And the bucket name is my target bucket. 56 00:02:10,860 --> 00:02:12,540 So I need to actually enter the name. 57 00:02:12,540 --> 00:02:15,000 So we'll take this bucket right here, 58 00:02:15,000 --> 00:02:16,860 copy and paste it. 59 00:02:16,860 --> 00:02:18,180 Okay, and as you can see, 60 00:02:18,180 --> 00:02:20,040 the destination region was identified 61 00:02:20,040 --> 00:02:22,470 as being us-east-1. 62 00:02:22,470 --> 00:02:26,040 So therefore, this is a Cross-Region Replication. 63 00:02:26,040 --> 00:02:27,090 Okay. 64 00:02:27,090 --> 00:02:28,080 Now for IAM role, 65 00:02:28,080 --> 00:02:31,830 we need to actually go and create a new role for this. 66 00:02:31,830 --> 00:02:32,913 So here's the option. 67 00:02:33,840 --> 00:02:36,300 And then we can have a look at some settings 68 00:02:36,300 --> 00:02:38,700 but for now it doesn't really matter for us. 69 00:02:38,700 --> 00:02:39,843 Let's just save this. 70 00:02:41,790 --> 00:02:43,890 So we get a prompt right here, 71 00:02:43,890 --> 00:02:46,980 which says do you want to replicate existing objects? 72 00:02:46,980 --> 00:02:49,860 So it turns out that when you do enable replication, 73 00:02:49,860 --> 00:02:51,510 it will only replicate objects 74 00:02:51,510 --> 00:02:52,860 from the moment you set it. 75 00:02:52,860 --> 00:02:54,570 So for newer uploads. 76 00:02:54,570 --> 00:02:58,800 So if you wanted to replicate the previous objects 77 00:02:58,800 --> 00:03:00,810 from the source to the destination bucket, 78 00:03:00,810 --> 00:03:03,720 you could use something called a Batch Operation, 79 00:03:03,720 --> 00:03:06,365 an S3 Batch Operation to do so 80 00:03:06,365 --> 00:03:09,690 and you would need to say yes, replicate existing objects. 81 00:03:09,690 --> 00:03:10,890 But this is separate 82 00:03:10,890 --> 00:03:13,500 from the replication feature itself. 83 00:03:13,500 --> 00:03:15,420 Therefore, I'm going to say no, 84 00:03:15,420 --> 00:03:17,910 do not replicate existing objects. 85 00:03:17,910 --> 00:03:19,470 And we're good to go. 86 00:03:19,470 --> 00:03:20,820 So now let's have a look. 87 00:03:20,820 --> 00:03:23,670 So we have this Management 88 00:03:23,670 --> 00:03:26,850 with a replication rule that is ready. 89 00:03:26,850 --> 00:03:28,230 And now what I'm going to do 90 00:03:28,230 --> 00:03:30,600 is check in my replica bucket. 91 00:03:30,600 --> 00:03:32,640 Of course, if I refresh now, 92 00:03:32,640 --> 00:03:35,193 we see that the objects haven't been replicated. 93 00:03:36,090 --> 00:03:38,250 So I'm going to do is now upload a new file, 94 00:03:38,250 --> 00:03:41,850 for example, upload the coffee.jpg file. 95 00:03:41,850 --> 00:03:42,723 Upload it. 96 00:03:43,860 --> 00:03:44,850 We're done. 97 00:03:44,850 --> 00:03:47,040 So here is the coffee.jpg file. 98 00:03:47,040 --> 00:03:48,210 Let's show the versions. 99 00:03:48,210 --> 00:03:51,483 So this is coffee.jpg and the version is GBk. 100 00:03:52,905 --> 00:03:53,970 Okay, perfect. 101 00:03:53,970 --> 00:03:58,020 Now if we go in my target bucket, and refresh this, 102 00:03:58,020 --> 00:04:00,600 it's gonna take maybe five seconds. 103 00:04:00,600 --> 00:04:02,730 And this took about 10 seconds on the first replication 104 00:04:02,730 --> 00:04:04,890 but we can see that my coffee.jpg 105 00:04:04,890 --> 00:04:07,830 has been added into my replica bucket. 106 00:04:07,830 --> 00:04:09,390 And if I show the versions, 107 00:04:09,390 --> 00:04:12,300 we can see that the version ID of my coffee.jpg 108 00:04:12,300 --> 00:04:15,270 is the exact same of the origin bucket. 109 00:04:15,270 --> 00:04:17,790 So the version's IDs are replicated, 110 00:04:17,790 --> 00:04:18,870 which is great. 111 00:04:18,870 --> 00:04:20,970 And if I wanted to import the beach.jpg, 112 00:04:20,970 --> 00:04:23,700 I would need to upload a new version of that file. 113 00:04:23,700 --> 00:04:26,403 So let's upload beach.jpg again. 114 00:04:29,220 --> 00:04:30,390 Now this has been uploaded, 115 00:04:30,390 --> 00:04:31,380 we can look at the versions, 116 00:04:31,380 --> 00:04:34,230 so there is a new version right here 117 00:04:34,230 --> 00:04:38,130 of DK2 of my beach.jpg file. 118 00:04:38,130 --> 00:04:41,163 And now if I go here and refresh, 119 00:04:42,060 --> 00:04:43,500 now let's look at one more setting 120 00:04:43,500 --> 00:04:45,360 that is important for your exam. 121 00:04:45,360 --> 00:04:47,760 So if I go back into Management, 122 00:04:47,760 --> 00:04:50,850 and take this and edit this role, 123 00:04:50,850 --> 00:04:52,710 we can scroll down and have a look 124 00:04:52,710 --> 00:04:55,890 at one setting called the delete marker replication. 125 00:04:55,890 --> 00:04:57,570 So by default, delete markers 126 00:04:57,570 --> 00:04:59,070 are not replicated 127 00:04:59,070 --> 00:05:00,450 but there's a feature to do so. 128 00:05:00,450 --> 00:05:03,450 So if you enable delete marker replication, 129 00:05:03,450 --> 00:05:08,070 then they will be replicated from one bucket to another. 130 00:05:08,070 --> 00:05:09,570 So let's save this. 131 00:05:09,570 --> 00:05:12,300 So my replication rules have been saved. 132 00:05:12,300 --> 00:05:14,820 And so that means that if I go in this bucket, 133 00:05:14,820 --> 00:05:16,890 and I choose to delete this file, for example, 134 00:05:16,890 --> 00:05:20,940 I delete my coffee.jpg file, let's delete it. 135 00:05:20,940 --> 00:05:23,040 This will actually create a delete marker 136 00:05:23,040 --> 00:05:25,083 because my bucket is versioned. 137 00:05:26,370 --> 00:05:27,900 We're done. 138 00:05:27,900 --> 00:05:31,800 So now my coffee.jpg is deleted. 139 00:05:31,800 --> 00:05:33,450 And let's have a look in here. 140 00:05:33,450 --> 00:05:36,393 So let's refresh and we need to wait little bit. 141 00:05:37,290 --> 00:05:39,390 And now you can see that the delete marker 142 00:05:39,390 --> 00:05:42,390 has been replicated to my replica bucket. 143 00:05:42,390 --> 00:05:43,860 So if I don't show version, 144 00:05:43,860 --> 00:05:46,140 I don't see my coffee.jpg file 145 00:05:46,140 --> 00:05:48,630 but of course, if I show versions, I will see it. 146 00:05:48,630 --> 00:05:49,980 This is true here. 147 00:05:49,980 --> 00:05:52,380 And of course, this is true here as well. 148 00:05:52,380 --> 00:05:54,690 So the delete markers are deleted 149 00:05:54,690 --> 00:05:58,772 but if you decide to delete a specific version 150 00:05:58,772 --> 00:06:00,810 of a file, for example, 151 00:06:00,810 --> 00:06:05,130 I delete this one, which is I delete a specific version ID. 152 00:06:05,130 --> 00:06:07,500 So this is called the permanent delete. 153 00:06:07,500 --> 00:06:11,972 And if I permanently delete one object 154 00:06:11,972 --> 00:06:14,130 in my origin bucket, 155 00:06:14,130 --> 00:06:18,000 it will not be replicated to my replica bucket. 156 00:06:18,000 --> 00:06:20,940 So this beach.jpg here will never be deleted 157 00:06:20,940 --> 00:06:23,280 because only delete markers are replicated, 158 00:06:23,280 --> 00:06:25,050 not deletes, okay? 159 00:06:25,050 --> 00:06:26,550 So that's it for this lecture. 160 00:06:26,550 --> 00:06:29,500 I hope you liked it and I will see you in the next lecture.