By default, Amazon S3 stores multiple copies of your data inside different facilities within one AWS Region. In case of region-level disaster like tornado, flood or earthquake all these facilities will experience outage and despite all precautions your crucial data may be lost. Consequences are catastrophic, especially in case of user-generated content that can’t be easily reproduced.
This article explains how to Configure Cross-Region Replication between buckets in different AWS Regions to achieve region-level data protection.How to Enable Amazon S3 Cross-Region Replication
Please before enabling cross-region replication, mind that:
1. Cross region replication is not free. You will be billed according to the prices in the selected region
2. Before implementing Cross-Region Replication, make sure files you want to replicate are allowed by AWS.
Login to your AWS console and choose Amazon S3: https://s3.console.aws.amazon.com/s3/
Choose the needed bucket and click it
Click properties and enable Versioning. Cross-region replications works only with this feature enabled
Go to Management tab, find Replication in the sub-menu, and click Add a Rule. This will begin the cross-region replication setup
Select your source bucket. You can select a bucket, a given prefix or a tag to replicate only the needed parts of data in the bucket
You need a bucket in a different region to perform replication. Choose the existing one or create a new oneAdditionally you can choose different storage class for replication. That helps if you want to spend less for additional copies of your files.
Further reading Amazon S3 Storage Classes Explained
You need to select or create IAM role, that will allow automatic replication from one bucket to another.
Here is the basic rule that can be applied:
{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":[ "s3:GetReplicationConfiguration", "s3:ListBucket" ], "Resource":[ "arn:aws:s3:::source-bucket" ] }, { "Effect":"Allow", "Action":[ "s3:GetObjectVersion", "s3:GetObjectVersionAcl" ], "Resource":[ "arn:aws:s3:::source-bucket/*" ] }, { "Effect":"Allow", "Action":[ "s3:ReplicateObject", "s3:ReplicateDelete" ], "Resource":"arn:aws:s3:::destination-bucket/*" } ] }
Replication works for objects that are only created after enabling Cross-Region Replication.
Conclusion
Enabling Cross-Region replication will improve the protection of your data in case of the disaster that affects the whole region. You can also use replication to minimize latency for accessing objects for users from different AWS region.