DEV Community

Thu Kha Kyawe
Thu Kha Kyawe

Posted on

How To Configure Cross Region Replication for an S3 Bucket

1. Create an S3 bucket

  • Type S3 in AWS Console and click

  • Set Primary Bucket's Region as Singapore

  • select Create bucket.

  • Write bucket name as Unique Name

  • Click enable

  • Click Create bucket

  • Change Region for Backup Bucket

  • select Create bucket.

  • Write bucket name as Unique Name

  • Click enable

  • Click Create bucket

2. Configure Cross-Region Replication

  • Click Primary Bucket

  • Click Managment

  • Click Create replication rule

  • Write rule name

  • Select Apply to all objects in the bucket

  • Choose backup-bucket

  • Choose Create new role

[!NOTE]
You can create policy and rule by yourself too. If you want, please do the following until created policy and rule:

3. Create Policy and Rule at IAM

  • Type IAM in AWS Console and open as new tab

  • Click Policies

  • Click Create policy

  • Click json and delete default policy

  • Copy and paste the following policy, edit with your bucket arn and click Next
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "s3:ListBucket",
                "s3:GetReplicationConfiguration",
                "s3:GetObjectVersionForReplication",
                "s3:GetObjectVersionAcl",
                "s3:GetObjectVersionTagging",
                "s3:GetObjectRetention",
                "s3:GetObjectLegalHold"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::primary-bucket-23042024",
                "arn:aws:s3:::primary-bucket-23042024/*",
                "arn:aws:s3:::backup-bucket-23042024",
                "arn:aws:s3:::backup-bucket-23042024/*"
            ]
        },
        {
            "Action": [
                "s3:ReplicateObject",
                "s3:ReplicateDelete",
                "s3:ReplicateTags",
                "s3:ObjectOwnerOverrideToBucketOwner"
            ],
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::primary-bucket-23042024/*",
                "arn:aws:s3:::backup-bucket-23042024/*"
            ]
        }
    ]
}

Enter fullscreen mode Exit fullscreen mode
  • Write policy name and Click Create Policy

  • Click Roles

  • Click Create role

  • Choose S3 and Click Next

  • Choose TKK-S3-Cross-Region-Replication-Rule and Click Next

  • Write TKK-S3-Cross-Region-Replication-Rule and Click Create role

  • Go back to previous tab and choose TKK-S3-Cross-Region-Replication-Rule

  • Select Change the storage class for the replicated objects and then in Storage class, select Standard-IA.

  • Click Save

  • Click No, do not replicate existing objects. and then Click Submit

  • Select primary-bucket-23042024, and then select Upload.

  • Click Add files

  • select any file on your local computer, and click Open and then click Upload

  • Click Close

  • On the Buckets page, select backup-bucket-23042024 to view the file you just uploaded.

Congratulations, you have completed Lab-How To Configure Cross-Region Replication for an S3 Bucket


Repository: AWS Learning Labs

Top comments (0)