AWS S3 CROSS-REGION REPLICATION

Fatuase Fiyinfoluwa
4 min readNov 28, 2022

--

AWS Simple Storage Service (S3) is a popular cloud-based storage service offered by Amazon Web Services that stores data in the form of objects within resources called buckets. AWS S3 offers features like 99.999999999% durability, cross-region replication, event notifications, versioning, encryption, and flexible storage options (redundant and standard).

In the world of scalable cloud applications, replication is one of the most commonly used S3 features. Replication is a feature of the S3 bucket that makes real-time copies of objects stored in one S3 bucket in another S3 bucket or multiple buckets depending on the use case while maintaining the original object’s metadata such as the actual object creation times and version IDs.

Cross-region replication allows you to store an object in one AWS region and get it automatically replicated in another region. Cross-region replication can be used to optimize cloud infrastructures for high availability and reduce latency by maintaining object copies in AWS regions that are closer to the infrastructure end-users. Cross-region replication can also be used for disaster recovery when the primary S3 bucket is not available or gets deleted and the other bucket(s) serves as the backup. Other use cases of cross-region replication include satisfying compliance requirements and increasing operational efficiency.

Setting Up S3 Cross-Region Replication

Step 1: Creating S3 buckets in different regions

To set up cross-region replication in S3, you first need to create the primary bucket and the secondary bucket that will serve as the main bucket and backup bucket respectively, in different AWS regions. To do this, click on CREATE BUCKET in the AWS S3 management console.

Enter a unique name for your primary bucket in the bucket name section, the region you want the primary bucket to be situated in the AWS Region section.

Enable bucket versioning to keep multiple variants of an object in the same bucket.

Click Create Bucket.

The same process is applied to create the secondary bucket (backup)with a unique name for the secondary bucket and a different AWS region to be situated in.

Enable bucket versioning for the secondary bucket

Click on the Create bucket

Step 2: Creating Replication Rule

After successfully creating the buckets in different regions, creating a replication rule in the primary bucket (which is also the source bucket) that points to the secondary bucket as the destination bucket is the next step.

Click on the primary bucket in the S3 management console and navigate to the management option at the top.

Scroll down to the replication rules section after the lifestyle cycle section and click on Create replication rule

Enter a name for your replication rule

Select Apply to all objects in the bucket in the rule scope

Click on Browse S3 to select the secondary bucket as the destination

Select the secondary bucket as the destination and click on Choose Path

An IAM role that AWS S3 can assume to replicate objects automatically is needed

Select Choose from existing IAM roles in the IAM roles section, click on the dropdown and select Create new role. An IAM role with the necessary permissions to carry out replication automatically gets created.

Save the replication rule.

A prompt that asks us to select if we want to replicate existing objects in the bucket, comes up. Select No, do not replicate existing objects since there are no existing objects in the primary bucket and click Submit. A replication rule has been created successfully.

The creation of the replication rule completes the set-up of AWS S3 cross-region and it can be tested after some minutes by uploading a file into the primary bucket and checking the secondary bucket to confirm if it gets replicated.

--

--

No responses yet