Copy data from an S3 bucket to another account and Region by using S3 Batch Replication
Created by Appasaheb Bagali (AWS), Lakshmikanth B D (AWS), Purushotham G K (AWS), Shubham Harsora (AWS), and Suman Rajotia (AWS)
Environment: PoC or pilot | Technologies: Storage & backup | AWS services: Amazon S3; AWS Identity and Access Management |
Summary
This pattern explains how you can use Amazon Simple Storage Service (Amazon S3) Batch Replication to copy the contents of an S3 bucket to another S3 bucket automatically, without any manual intervention, after you set up the buckets. The source and destination buckets can be in the same or in different AWS accounts or Regions.
S3 Batch Replication gives you a way to replicate Amazon S3 objects that existed before a replication configuration was in place, objects that were previously replicated, and objects that failed replication. This method uses an S3 Batch Operations job. When the job finishes, you receive a completion report.
You can use S3 Batch Replication in scenarios that require continuous and automatic migration of new objects from a source bucket to a destination bucket. For one-time migration, you can use the AWS Command Line Interface (AWS CLI) instead, as described in the pattern Copy data from an S3 bucket to another account and Region by using the AWS CLI.
Prerequisites and limitations
A source AWS account.
A destination AWS account.
An S3 bucket in the source account with a few objects (files or folders).
One or more S3 buckets in the destination account.
S3 Versioning enabled on the source and destination buckets.
AWS Identity and Access Management (IAM) permissions to create an IAM policy, IAM role, and S3 bucket policy on the source and destination accounts.
Amazon S3 Lifecycle rules disabled while the S3 Batch Replication job is active. This ensures parity between the source and destination buckets. Otherwise, the destination bucket might not be an exact replica of the source bucket.
Architecture
Tools
AWS services
AWS Identity and Access Management (IAM) helps you securely manage access to your AWS resources by controlling who is authenticated and authorized to use them.
Amazon Simple Storage Service (Amazon S3) is a cloud-based object storage service that helps you store, protect, and retrieve any amount of data.
Best practices
The following video from AWS re:Invent 2022 discusses best practices for using Amazon S3 replication for regulatory compliance, data protection, and increased application performance.
Epics
Task | Description | Skills required |
---|---|---|
Create an IAM policy for cross-account replication. | In the AWS source account:
For more information, see Creating IAM policies in the IAM documentation. | Cloud administrator, AWS administrator |
Create an IAM role for cross-account replication. | In the AWS source account:
For more information, see Creating IAM roles in the IAM documentation. | Cloud administrator, AWS administrator |
Task | Description | Skills required |
---|---|---|
Create a replication rule against the source bucket in the source account. | In the AWS source account:
For more information, see Configuring replication when source and destination buckets are owned by different accounts in the Amazon S3 documentation. | AWS administrator, Cloud administrator |
Task | Description | Skills required |
---|---|---|
Apply a bucket policy to the destination bucket. | This step has to be performed for each destination bucket individually in AWS destination accounts. In the AWS destination account:
This policy includes two statements:
| AWS administrator, AWS systems administrator, Cloud administrator |
Task | Description | Skills required |
---|---|---|
Verify that replication works correctly. |
For more information, see Monitoring metrics with Amazon CloudWatch in the Amazon S3 documentation. | AWS administrator, Cloud administrator |
Related resources
When do I use IAM? (IAM documentation)
How IAM works (IAM documentation)
Creating IAM roles (IAM documentation)
Creating IAM policies (IAM documentation)
Overview of access management: Permissions and policies (IAM documentation)
Creating, configuring, and working with Amazon S3 buckets (Amazon S3 documentation)
Uploading, downloading, and working with objects in Amazon S3 (Amazon S3 documentation)
Replicating objects (Amazon S3 documentation)