Tuesday, March 15, 2022

AWS Storage - S3 Cross Region Replication


https://docs.aws.amazon.com/AmazonS3/latest/userguide/replication.html

Replication requires the following:

  • The source bucket owner must have the source and destination AWS Regions enabled for their account. The destination bucket owner must have the destination Region enabled for their account.

  • Both source and destination buckets must have versioning enabled.

  • Amazon S3 must have permissions to replicate objects from the source bucket to the destination bucket or buckets on your behalf.

  • If the owner of the source bucket doesn't own the object in the bucket, the object owner must grant the bucket owner READ and READ_ACP permissions with the object access control list (ACL). 

  • If the source bucket has S3 Object Lock enabled, the destination buckets must also have S3 Object Lock enabled.


What is replication?
  • Replication enables automatic, asynchronous copying of objects across Amazon S3 buckets. 
  • Buckets with object replication configuration is owned by the same AWS account or by different accounts. 
  • You can replicate objects to a single destination bucket or to multiple destination buckets. 
  • The destination buckets can be in different or same AWS Regions.

Same-Region Replication (SRR) or Cross-Region Replication (CRR): To automatically replicate new objects as they are written to the bucket use live replication.
S3 Batch Replication: To replicate existing objects to a different bucket on demand, use .


To enable SRR or CRR:
Step1: add a replication configuration to your source bucket and the minimum configuration must provide the following:
  • The destination bucket or buckets where you want Amazon S3 to replicate objects
  • An AWS Identity and Access Management (IAM) role that Amazon S3 can assume to replicate objects on your behalf

To make S3 Batch Replication:

Cross-Region Replication enables an automatic, asynchronous copying process between the buckets
Configured Buckets can be owned by a single account or they can be from a different account.
Destination bucket can be the different or same region

Step 1: Create a source bucket (srcbucket) in a region ( Mumbai ap-south-1) and Enable the versioning.
Step 2: Create a destination bucket (destbucket) in a different region ( North Virginia us-east-1) and enable the versioning.
Step 3: Select Source bucket and Click on Management Tab.
Step 4: Click on Create Replication Rule and Provide the below information
  • Replication rule name: ReplicaRule1
  • Status: Enable
  • Priority: 0
  • Source bucket: Apply to all objects in the bucket.
Step 5: Select the destination bucket.
  • Select option choose a bucket from this account
  • Click on browse s3 button
  • Select destination bucket
Step 6: IAM Role: Choose from existing IAM role:
  • Create your own role (this will create something like S3crr_bucket_irfan)
Step 7: Encryption :- unchecked
Step 8: Destination Storage class: unchecked
Step 9: Click on save button
Step 9.1: if asked if want to replicate existing content: click no for now.
Step 10: Upload a file in the source bucket and it should be copied in the destination bucket as well.


Experiment:
1. Delete the file from the source bucket and check whether it is deleted in the destination bucket or not.
Ans: The file still persists in the destination bucket.
2. Try to disable the versioning of either of these buckets.
Ans: disable versioning in source bucket is not allowed as crr rule is present in the source bucket.
but disable versioning in destination bucket is allowed.
when versioning is disabled in bucket, no new files will be replicated in the destination bucket.

No comments:

Post a Comment

Fluentd

Open-source log data collector > why logs? - for compliance (auditing, company, business) - for security (transparency, monitoring, admin...