Cross-region replication (CRR) :
It enables automatic, asynchronous copying of objects across buckets in different AWS Regions. Buckets configured for cross-region replication can be owned by the same AWS account or by different accounts.
So basically Cross region replication is used when one needs to replicate a bucket from one region to other.
Cross region replication between two buckets :
Create two buckets but both should have different regions.
For example: first bucket – crossbucket1992 in EU(Paris) region.
Next important thing is to enable versioning, leave other settings as default and move to create bucket.
Second bucket : crossbucket1993 in EU(London) region.
Like you did for the first bucket, enable versioning, leave other settings as default and move to create bucket.
Both the buckets have been created successfully.
Adding objects to the bucket
Add object to the first bucket, click the bucket to get inside it, then click upload to add new file.
To view file you need to go to Actions and then click make public.
File can be viewed using object url.
Enabling cross region replication
- In the bucket click Management, click Replication and then click Add rule for cross region replication.
- Set Source: you can either select entire bucket or use some tags or prefix to be replicated. Encryption can also be turned on.
For now select entire bucket and move to the next step.
- Set Destination: select the bucket name. You can also change the storage class and object ownership.
Select the second bucket i.e crossbucket1993 as destination bucket.
- Set IAM role, select create new role and the write rule name, move to next.
- Review the replication rules and then save. You will receive a message : Replication configuration updated successfully.
When you open the second bucket: crossbucket1993 , you would not see anything. Come back to the first bucket : crossbucket1992, upload a new object in the bucket.
Click Upload to add new file and after the file is uploaded, go to the Actions and click make public.
Use the object url to view the file
open the second bucket: crossbucket1993 and see whether something has changed or not. The object has been replicated in this bucket, but to view the file again you have to make it public.
Again go back to the first bucket: crossbucket1992 and delete the file you uploaded.
Then come back to the Second bucket: crossbucket1993 to see if the file is deleted or not. But it is still present.
Things to remember:
Cross region replication requires bucket versioning in both the buckets.
Regions of the bucket should not be same.
After the cross region replication rule is saved or turned on and new changes are made in the original bucket, it will be shown in the replicated bucket also.
If we delete or put delete markers in original bucket it will not be affected to the replicated bucket.