AWS S3 Bucket Replication
If you are backing up your data to S3 bucket and looking to replicate to be extra cautious then you have found an appropriate post. In this post, we will be covering high-level s3 replication options and use cases. Also, focus on the same region replication using complete Terraform source code. Complete Source code can be found here.
Replication Options
Same Region Replication (SRR) is used to copy objects across Amazon S3 buckets in the same AWS Region.
Use of SRR
- Aggregate logs into a single bucket
- Configure live replication between production and test accounts
- Abide by data sovereignty laws
Cross-Region Replication (CRR) is used to copy objects across Amazon S3 buckets in different AWS Regions.
Use of CRR
- Meet compliance requirements
- Minimize latency
- Increase operational efficiency
How Replication works
**NOTE — Replication requirements
* Versioning on source and destination bucket must be enabled
* Object Locking must not be enabled
Steps to setup replication using Terraform
Setup IAM Role to enable Replication
- Create an IAM Role to enable S3 Replication,
- Create an IAM Policy
- Attach the policy to Role.
Setup Destination Bucket (replicate data to)
- Create Destination Bucket with bucket policy
- Enable Versioning
Setup Source Bucket (replicate data from)
- Create Source Bucket
- Enable Versioning
Get up and Running
Find complete source code here
Clone Repository and follow instructions in README.md file
git clone https://github.com/maxyermayank/terraform-s3-bucket-replication
DEMO
Feel free to make a contribution. Make sure to follow best practices for your deployment.