Cross-Region Bucket Replication of Existing Data Using Amazon S3 Batch Operation
Tags: aws, amazons3, iamrole, s3batchoperations
Published: 2023-11-18 14:34:49

“ I have checked the documents of AWS to do cross-region bucket replication of existing data using amazon s3 batch operation. Pricing of S3 bucket as per storage size and S3 batch job replication as per $0.25 per job.” 

An S3 Batch Operations is a data management functionality in Amazon S3 that allows you to handle billions of items at scale with only a few clicks in the Amazon S3 Management Console or a single API request. With S3 Batch Operations, you can make changes to object metadata and properties, as well as perform other storage management tasks such as copying or replicating objects between buckets, replacing object-tag sets, modifying access controls and restoring archived objects from S3 Glacier. 

A single job can execute a specific operation on billions of objects carrying exabytes of data. It manages retries, tracks progress, sends notifications, generates completion reports and delivers events to AWS Cloudtrail for all changes made and tasks executed.

In this post, you will get to know how to do cross-region bucket replication of existing data using amazon s3 batch operation. Here I have created a s3 bucket, IAM role, S3 replication rule and s3 batch operation.

#Prerequisites
You’ll need an Amazon Simple Storage Service for this post. [Getting started with Amazon Simple Storage Service](https://aws.amazon.com/s3/getting-started/) provides instructions on how to create a bucket in simple storage service.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s6cqb9hdkv1m66j56tip.jpg)
The architecture diagram shows the overall deployment architecture with data flow, amazon s3 and iam role.

#Solution overview
The blog post consist of the following phases:
1. Create of IAM Replication Role and Replication Rule on Source Bucket
2. Create of IAM Batch Role and Replication Job
3. Output of S3 Batch Operation

I have s3 buckets as below →

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gvoarxhvhf33bqk5yy18.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vg0vhafbvzksf1g692zd.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g7zkco8ef4lbs1g4iti2.png)

##Phase 1: Create of IAM Replication Role and Replication Rule on Source Bucket 
1. Open the IAM console and create a replication role with required permission. Also open the source bucket, create a replication rule under the management section.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0l52slmz0pj2j2of0qqy.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/doapvpvew4mbzh9rp8tg.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fwcj5kqj8uk64hpcvnqk.png)

##Phase 2: Create of IAM Batch Role and Replication Job
1. Open the IAM console and create a batch role with required permission. Also open the source bucket, create a replication job.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/70r4wpmfnpdkwwuutrgy.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hq503s4whhxjaej54gyv.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ypd9vx13h2tz96x7ibt3.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9phz5czfj07kvbcncsj9.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mzpnpdsi5f3u6symunnx.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fwb00wj44og3rfqj33yr.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8jxqculvq96ry0agw4j0.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wsi5owsf53ikg5qzafum.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/szcqkr0meeht9jqa1x31.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6mndebk3osrzhjqdnu32.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/97ejjid95nhko7i0dc33.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t9lnew0b0fbke3e1owly.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x97yv7p4eg2zg76ngmme.png)

##Phase 3: Output of S3 Batch Operation

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22ifooexvfgp8sece3be.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sq2cgtsu31kx69et1rqz.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j2wn3p7a1enl0fkneazm.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6g85u8rnpf59j003c8to.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n6xkfzikwbziikfa1pem.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8b8t9hlemknseaja3shh.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/45uljstxs2kimdpxdsma.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z1arlz29x9eacv9ny9fx.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64gpgw4sbkc10on7dtrn.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91hcrxxnvnndq886s0ib.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qv80aniktcbz6xq1mwtf.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnsgd9hcg5cmjj7ww3a7.png)

#Clean-up
Delete S3 Bucket and IAM Role.

#Pricing
I review the pricing and estimated cost of this example.

Cost of S3 in N. Virginia = $0.232

Cost of S3 in Oregon = $0.232

S3 Batch Replication for Job = $0.25 

Total Cost = $0.714

#Summary
In this post, I showed “cross-region bucket replication of existing data using amazon s3 batch operation”.

For more details on Amazon S3 Batch Operations, Checkout Get started Amazon S3 Batch Operations, open the [Amazon S3 Batch Operations console](https://s3.console.aws.amazon.com/s3/jobs?region=us-east-1). To learn more, read the [Amazon S3 Batch Operations documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/batch-ops-create-job.html).

For more details on IAM, Checkout Get started IAM, open the [IAM console](https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/home). To learn more, read the [IAM documentation](https://docs.aws.amazon.com/iam/).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)