Becoming Proficient in Data Resilience: Practical Applications of S3 Replication Rules and Versioning on AWS S3
What is S3 Replication ?
S3 replication within AWS involves automatically duplicating data from one Amazon Simple Storage Service (S3) bucket to another. This duplication can happen within the same AWS region or across different regions, offering redundancy, disaster recovery, and data localization options.
There are 2 types of replication carried out,
S3 Same-Region Replication (SRR):
This type of replication in S3 entails duplicating objects within the confines of a single AWS region. Typically employed for redundancy purposes within the same geographic locale, it guarantees heightened data availability and durability.
S3 Cross-Region Replication (CRR):
Cross-region replication in S3 involves automatically copying objects from an S3 bucket in one AWS region to another bucket in a distinct AWS region. This practice is commonly implemented for disaster recovery, safeguarding data availability in the event of an entire AWS region becoming inaccessible.
What is S3 Versioning ?
S3 versioning in AWS is a functionality offered by Amazon Simple Storage Service (S3) that permits the retention of multiple versions of an object within a single bucket. When versioning is activated for a bucket, S3 generates a new version of an object each time it undergoes an update or deletion. This capability facilitates the recovery of prior versions of objects in the event of accidental alterations or removals.
Let's engage in a hands-on exercise to grasp the functioning of S3 replication within the same region alongside versioning,
- Please create a bucket named "s3-replication-test-source-2024" and enable versioning for it.
- Create an another bucket named as s3-replication-test-destination-2024. Enable the bucket versioning for the bucket.
Now we have created 2 buckets in the same region with the bucket versioning enabled.
Now go to the IAM console and click on the Roles followed up by creating a new role.
Select the Custom Trust policy and get the below policy appended. Name the role as SRR-S3.
{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Principal":{ "Service":"s3.amazonaws.com" }, "Action":"sts:AssumeRole" } ] }
Attach the inline policy for the replication rule. Get the arn of the source and target buckets
{
"Version":"2012-10-17",
"Statement":[
{
"Effect":"Allow",
"Action":[
"s3:GetReplicationConfiguration",
"s3:ListBucket"
],
"Resource":[
"arn:aws:s3:::SOURCE-BUCKET"
]
},
{
"Effect":"Allow",
"Action":[
"s3:GetObjectVersionForReplication",
"s3:GetObjectVersionAcl",
"s3:GetObjectVersionTagging"
],
"Resource":[
"arn:aws:s3:::SOURCE-BUCKET/*"
]
},
{
"Effect":"Allow",
"Action":[
"s3:ReplicateObject",
"s3:ReplicateDelete",
"s3:ReplicateTags"
],
"Resource":"arn:aws:s3:::DESTINATION-BUCKET/*"
}
]
}
Now click on the s3-replication-test-source-2024 and click on the Management tab and click on the replication rule.
Confirm the source bucket and check in the role scope to all object. Specify the destination bucket as well.
Select the IAM Role we created.
Finally select the Yes option to replicate the existing objects so that the current objects gets replicated.
Now upload a file in the source folder and automatically the replication would have taken place.
SOURCE FOLDER:
DESTINATION FOLDER:
Now lets create a version of the object file that we have already uploaded. Upload the same file again into the source S3 bucket. Click on the toggle button of "show version" to see the versioning of the objects.
To summarize, S3 replication and versioning in AWS provide effective data management options for cloud-based businesses. Replication guarantees redundancy and disaster recovery, whether within the same region or across different ones. Meanwhile, versioning safeguards against unintended data loss or corruption by preserving multiple object versions. By utilizing these functionalities, AWS users can bolster data resilience, availability, and security, enabling them to construct scalable and dependable cloud architectures.
Subscribe to my newsletter
Read articles from Yukesh K directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by