Replication of S3 Objects from Source Region Encrypted Bucket to Destination Region Encrypted Bucket
Tags: aws, kms, s3, iam
Published: 2023-01-17 18:37:17

“ I have checked the ways of AWS to do replication of encrypted s3 buckets in the cross region. Pricing of S3 bucket as per storage size and kms as per key”

Replication enables automatic, asynchronous copying of objects across Amazon S3 buckets. Buckets that are configured for object replication can be 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 AWS Regions or within the same Region as the source bucket.

In this post, you will get to know how to do replication of s3 objects from source region encrypted bucket to destination region encrypted bucket. Here I have created s3 bucket, kms key and Iam role with policy.

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

#Solution overview
The blog post consist of the following phases:
1. Create of S3 Buckets with Versioning Enabled and Encrypted Key on Buckets
2. Create of IAM Role and Policy with Replication Rule
3. Output as Replicated Objects of Source Region Bucket to Destination Region Bucket

##Phase 1: Create of S3 Buckets with Versioning Enabled and Encrypted Key on Buckets
1. Open the S3 console and create two buckets with versioning enabled. Also create two customer managed keys in the kms console and encrypt both the buckets with the keys as SSE-KMS.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

##Phase 2: Create of IAM Role and Policy with Replication Rule
1. Open the IAM console and create a policy for replication of s3 bucket objects. Also create a role and attach policy on it. Create a replication rule on the source bucket with required configurations and IAM role attached on it.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

##Phase 3: Output as Replicated Objects of Source Region Bucket to Destination Region Bucket

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

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

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

#Clean-up
Delete S3 Bucket, CMK Key, IAM Role and IAM Policy.

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

Cost of S3 in N. Virginia = $0.66

Cost of S3 in Oregon = $0.232

Cost of Key Management Service in N. Virginia = $0.001

Cost of Key Management Service in Oregon = $0.00

Total Cost = $0.893

#Summary
In this post, I showed “replication of s3 objects from source region encrypted bucket to destination region encrypted bucket”.

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/).

For more details on Key Management Service, Checkout Get started Key Management Service, open the [Key Management Service Console](https://ap-south-1.console.aws.amazon.com/kms/home?region=ap-south-1#/kms/keys). To learn more, read the [Key Management Service Documentation](https://docs.aws.amazon.com/kms/?id=docs_gateway).

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)