Replication of Repo Data with Existing Commits to Another Repo Using Remote Origin
Tags: aws, awscodecommit, awsec2instance, awsiamrole
Published: 2023-06-24 14:46:51

“ I have checked the documents of AWS to resolve the issue of replicating one repo to another repo from the command line. So I got git remote origin as a solution. Pricing of solution depends on codecommit and ec2 instance cost.”

AWS Codecommit is a version control service hosted by AWS that you can use to privately store and manage assets in the cloud.

In this post, you will get to know how to do replication of repo data with existing commits to another repo using remote origin. Here I have used an ec2 server, iam role and codecommit repositories for replication of repo data with commits history to another repo using git remote origin.

#Prerequisites
You’ll need an AWS CodeCommit Repositories for this post. [Getting started with AWS CodeCommit](https://aws.amazon.com/codecommit/features/) provides instructions on how to create a codecommit repository. For this blog, I assume that I have two codecommit repositories created.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zs75mruloog6voa26nfc.jpg)
The architecture diagram shows the overall deployment architecture with data flow, amazon ec2, git remote origin commands and aws codecommit repos.

#Solution overview
The blog post consists of the following phases:
1. Create EC2 Instance and IAM Role. Run of Commands for Replication of One Repo Data with Commits to Another Repo
2. Output of Replicated Data and Commits from One Repo to Another Repo

I have two codecommit repositories and one repo “testrepo-1” contains data with commits history as below →

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

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

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

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

##Phase 1: Create EC2 Instance and IAM Role. Run of Commands for Replication of One Repo Data with Commits to Another Repo  
1. Launch of EC2 Instance and Creation of IAM role. Open the EC2 Connect console of instance, run the git commands to change the remote origin of the repository and replicate the data with commits of one repo to another repo.

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

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

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

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

##Phase 2: Output of Replicated Data and Commits from One Repo to Another Repo

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

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

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

#Clean-up
Delete EC2 Instance, IAM Role and CodeCommit Repository.

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

Cost of EC2 Instance = $0.09

Cost of CodeCommit = $0.00 for first 5 CodeCommit users = $0.0

Total Cost = $(0.09 + 0.0) = $0.09

#Summary
In this post, I showed “how to do replication of repo data with existing commits to another repo using remote origin”.

For more details on AWS CodeCommit, Checkout Get started AWS CodeCommit, open the [AWS CodeCommit console](https://us-east-1.console.aws.amazon.com/codesuite/codecommit/repositories?region=us-east-1). To learn more, read the [AWS CodeCommit documentation](https://docs.aws.amazon.com/codecommit/?icmpid=docs_homepage_devtools).

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)