- Cross Region Replication
- Cross Account Replication
- S3 Replication Time Control
- Multi Destination Replication
- Two-way Replication
- Replication metrics and notifications
Cross Region Replication
In cross region replication, the source and destination S3 buckets are in different AWS regions and replication takes place across the region.
Cross Account Replication
In cross account replication, the source and destination S3 buckets are in different AWS accounts. The data is replicated from S3 bucket in one AWS account to another S3 bucket in another AWS account.
S3 Replication Time Control
S3 replication time control is the latest feature provided by AWS S3 to replicate 99.99% of all your data from source S3 bucket to destination S3 bucket within the first 15 minutes. It replicates billions of S3 objects from source bucket to destination bucket within the first 15 minutes.
Multi Destination Replication
In order to replicate data from one source S3 bucket to multiple destination S3 buckets, now AWS S3 provides multi destination replication capability. This capability can be used to replicate data within or across the regions into multiple buckets.
Two-way Replication
In two-way replication, AWS S3 provides replication of data from source to destination bucket and vice versa. The replication takes place in both the directions and this can be used to build a common dataset across the regions.
Replication Metrics and Notifications
S3 replication provides metrics and notifications regarding data replication. You can check the replication progress minute by minute in the console.
In this blog, we will discuss how we can enable replication on AWS S3 buckets to replicate the object across different S3 buckets.
Creating S3 Replication Rules on AWS S3
First of all, we need to create two buckets in the AWS S3 console, one as source and other as the destination. In order to enable S3 replication, it is necessary to enable versioning on both the S3 buckets. Visit the following link to learn how S3 bucket versioning can be configured.
https://linuxhint.com/configure-aws-s3-bucket-versioning/
For this demo, we have created two S3 buckets in different AWS regions as shown in the following image. Both the buckets have versioning enabled on them.
The source S3 bucket is in the us-east-1 (N. Virginia) region and the destination S3 bucket is in the southeast-2 (Sydney) region.
After creating the S3 bucket, now open the source bucket by clicking on it and go to the Management tab of the source S3 bucket.
In the Management tab, scroll down to the Replication rules section and click on the Create replication rule button.
It will open a new page asking for the details of the replication rule. Enter the name of the replication rule and select the Enabled button to enable the rule.
Scroll down and now it will ask for the source bucket configurations whether all the objects in S3 are going to be replicated or some specific objects. For this demo, we will apply the replication rule to all the S3 objects in the bucket.
For the destination bucket configuration, it will ask for the destination bucket in which the source bucket will replicate the objects. The destination bucket may be in the same AWS account or different AWS account. For this demo, we will select the destination bucket in the same account but different region.
After selecting the source and destination S3 buckets, now it is time to attach an IAM role to S3 which will allow S3 to replicate the data from source S3 bucket to destination S3 bucket. You can either select an existing role or create a new role. For this demo, we will create a new role.
After IAM role configuration, it will ask if you want to enable different features of S3 replication or not. We can enable replication time control, replication metrics and notification, delete marker replication and replica modification sync.
Now, leave all the options as default and click on the save button at the bottom of the page to create the replication rule. You can see the newly created replication rule on the Management tab.
After creating the rule, now go to the source S3 bucket and upload some data in it.
After uploading data into the source S3 bucket, go to the destination bucket and check if the data is replicated from source S3 bucket or not.
We can see the data is successfully replicated from source S3 bucket to destination S3 bucket across the region.
So now, check if deleting the file from source S3 bucket actually deletes the file from destination bucket or not. Delete the file from source S3 bucket from console and go to the destination bucket.
But the file in the destination bucket is still available and is not deleted. To check this behavior, click on the show versions toggle button in the source S3 bucket and it will show the delete marker on the deleted file. Actually, when a file is deleted from S3 bucket with versioning enabled, the file is not deleted but S3 puts a delete marker on the file. And in the destination bucket, it does not delete.
But if a file is updated in the source S3 bucket, the change will be replicated from source S3 bucket to destination S3 bucket.
Conclusion
AWS S3 provides us with a number of functionalities to manage our data replication across S3 buckets within or different AWS regions and accounts. We can analyze data replication by using the replication metrics, if enabled, in the S3 console. In this demo, we discussed how we can configure S3 replication across different S3 buckets within or across the regions.