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,888 ‫For this, we're going to create a new bucket. 4 00:00:05,888 --> 00:00:10,843 ‫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 one. 7 00:00:15,720 --> 00:00:17,040 ‫This will be my origin buckets 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:28,080 ‫if versioning is enabled. 14 00:00:28,080 --> 00:00:29,530 ‫So I will create this bucket, 15 00:00:31,740 --> 00:00:34,050 ‫and then open this bucket in a new tab 16 00:00:34,050 --> 00:00:36,330 ‫and I will create a second bucket 17 00:00:36,330 --> 00:00:38,842 ‫and this will be my target bucket. 18 00:00:38,842 --> 00:00:43,280 ‫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 one 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 buckets. 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 buckets 30 00:01:11,280 --> 00:01:13,140 ‫and our secondary buckets. 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,350 ‫so I will add a file of my beach, 34 00:01:19,350 --> 00:01:21,063 ‫for example, beach.jpeg. 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:48,330 ‫So I'll call this one demo replication rule. 46 00:01:48,330 --> 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:52,560 ‫For the source bucket, 49 00:01:52,560 --> 00:01:53,730 ‫we'll leave it as is 50 00:01:53,730 --> 00:01:55,500 ‫and in terms of rule scope, 51 00:01:55,500 --> 00:01:58,830 ‫we'll apply it to all objects in the buckets. 52 00:01:58,830 --> 00:02:00,240 ‫Now for the destination, 53 00:02:00,240 --> 00:02:02,820 ‫we can specify a bucket in this account 54 00:02:02,820 --> 00:02:04,350 ‫or in other accounts, 55 00:02:04,350 --> 00:02:06,420 ‫and we'll choose one in this account 56 00:02:06,420 --> 00:02:10,860 ‫and the bucket name is my target bucket. 57 00:02:10,860 --> 00:02:12,540 ‫So I need to actually enter the name. 58 00:02:12,540 --> 00:02:16,860 ‫So I'll take this bucket right here, 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 one, 62 00:02:22,470 --> 00:02:26,040 ‫so therefore, this is a cross region replication. 63 00:02:26,040 --> 00:02:28,080 ‫Okay, now for IAM role, 64 00:02:28,080 --> 00:02:29,520 ‫we need to actually go 65 00:02:29,520 --> 00:02:31,830 ‫and create a new role for this. 66 00:02:31,830 --> 00:02:32,930 ‫So there'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 of 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,690 ‫an S3 batch operation to do so 80 00:03:06,690 --> 00:03:09,690 ‫and you would need to say yes, replicate existing objects, 81 00:03:09,690 --> 00:03:13,500 ‫but this is separate from the replication feature itself. 82 00:03:13,500 --> 00:03:15,420 ‫Therefore, I'm going to say no, 83 00:03:15,420 --> 00:03:17,910 ‫do not replicate existing objects 84 00:03:17,910 --> 00:03:19,470 ‫and we're good to go. 85 00:03:19,470 --> 00:03:20,820 ‫So now let's have a look. 86 00:03:20,820 --> 00:03:23,670 ‫So we have this management 87 00:03:23,670 --> 00:03:26,850 ‫with a replication rule that is ready. 88 00:03:26,850 --> 00:03:30,600 ‫And now what I'm going to do is check in my replica bucket. 89 00:03:30,600 --> 00:03:32,640 ‫Of course, if I refresh now, 90 00:03:32,640 --> 00:03:35,193 ‫we see that the objects haven't been replicated. 91 00:03:36,090 --> 00:03:38,250 ‫So I'm going to do is now upload a new file, 92 00:03:38,250 --> 00:03:41,850 ‫for example, upload the coffee.jpeg file, 93 00:03:41,850 --> 00:03:42,723 ‫upload it. 94 00:03:43,860 --> 00:03:44,850 ‫We're done. 95 00:03:44,850 --> 00:03:47,040 ‫So here is the coffee.jpeg file. 96 00:03:47,040 --> 00:03:48,150 ‫Let's show the version. 97 00:03:48,150 --> 00:03:51,483 ‫So this is coffee.jpeg and the version is GBK. 98 00:03:52,800 --> 00:03:53,970 ‫Okay, perfect. 99 00:03:53,970 --> 00:03:58,020 ‫Now, if we go in my target bucket and refresh this, 100 00:03:58,020 --> 00:04:00,600 ‫it's gonna take maybe five seconds. 101 00:04:00,600 --> 00:04:02,730 ‫And this took about 10 seconds on the first replication, 102 00:04:02,730 --> 00:04:04,890 ‫but we can see that my coffee.jpeg 103 00:04:04,890 --> 00:04:07,830 ‫has been added into my replica bucket. 104 00:04:07,830 --> 00:04:09,390 ‫And if I show the versions, 105 00:04:09,390 --> 00:04:11,250 ‫we can see the version ID 106 00:04:11,250 --> 00:04:15,300 ‫of my coffee.jpeg is the exact same of the origin bucket. 107 00:04:15,300 --> 00:04:18,870 ‫So the versions IDs are replicated, which is great. 108 00:04:18,870 --> 00:04:21,000 ‫And if I wanted to port the beach.jpeg, 109 00:04:21,000 --> 00:04:23,700 ‫I would need to upload a new version of that file, 110 00:04:23,700 --> 00:04:26,403 ‫so let's upload beach.jpeg again. 111 00:04:29,220 --> 00:04:30,390 ‫Now this has been uploaded. 112 00:04:30,390 --> 00:04:31,320 ‫We can look at the version. 113 00:04:31,320 --> 00:04:34,230 ‫So there is a new version right here 114 00:04:34,230 --> 00:04:38,130 ‫of DK2, of my beach.jpeg file. 115 00:04:38,130 --> 00:04:41,163 ‫And now if I go here and refresh, 116 00:04:42,150 --> 00:04:43,980 ‫and this took a bit of time, but as you can see, 117 00:04:43,980 --> 00:04:47,130 ‫you can find the DK2 version of that file. 118 00:04:47,130 --> 00:04:49,380 ‫So that's it for S3 bucket replication. 119 00:04:49,380 --> 00:04:50,280 ‫I hope you liked it 120 00:04:50,280 --> 00:04:52,230 ‫and I will see you in the next lecture.