S3 Cross-Region Replication

Verify S3 buckets

As part of the CloudFormation Template, the primary region and secondary region Amazon S3 buckets were created.

1.1 Click Amazon S3 to navigate to the dashboard.

1.2 The two S3 buckets begin with backupandrestore-. Note the regions for the two S3 buckets.

Create Replication rule

2.1 Click the link for backupandrestore-primary-uibucket-xxxx.

2.2 Click the Management link. In the Replication rule section, click the Create replication rule button.

2.3 Enter PrimaryToSecondary as the Replication rule name and select Apply to all objects in the bucket.

2.4 Select Choose a bucket in this account and then select backupandrestore-secondary-uibucket-xxxx as the Bucket name. Select Team Role as the IAM role.

2.5 Enable the Replication Time Control (RTC) checkbox, then click the Save button.

2.6 Our bucket is (almost) empty and we don’t want to replicate the existing objects, click the Submit button.

Replicate S3 bucket

We will manually copy objects into our backupandrestore-primary-uibucket-xxxx in our primary region so we can observe the replication into our backupandrestore-secondary-uibucket-xxxx bucket in our secondary region. In a production environment, we would automate these steps as part of our CI/CD pipeline.

3.1 Click AWS Cloudshell to navigate to the dashboard in the N. Virginia (us-east-1) region.

3.2 If you have never used CloudShell you will be prompted with a Welcome to AWS CloudShell message, click the Close button.

3.3 Once you see the prompt, paste the following AWS CLI command. You will be prompted with a Safe Paste for multiline text message, click the Paste button.

export S3_BUCKET=$(aws s3api list-buckets --region us-east-1 --output text --query 'Buckets[?starts_with(Name, `backupandrestore-primary-uibucket`) == `true`]'.Name)
aws s3 cp s3://ee-assets-prod-us-east-1/modules/630039b9022d4b46bb6cbad2e3899733/v1/UniShopUI/ s3://$S3_BUCKET/ --exclude "config.json" --recursive --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers    

Verify Replication

4.1 Click Amazon S3 to navigate back to the dashboard.

4.2 Click the link for backupandrestore-secondary-uibucket-xxxx.

4.3 You should see the replicated objects.

It might take a couple of minutes to replicate objects.