DEV Community

GargeeBhatnagar for AWS Community Builders

Posted on

Continuous Cloning of CodeCommit Repo in Multiple Regions Using CodeBuild and CodePipeline

“ I have to make a continuous clone of the code commit repository in multiple regions. I have checked various ways to do it but it's easy to do using codebuild and codepipeline. Pricing of codebuild and codecommit depends on commit users and build project time taken.”

AWS CodeBuild is a fully managed build service. It compiles your source code, tests and produces artifacts that are ready to deploy. It eliminates the need to provision, scale and manage build servers. It provides prepackaged build environments for programming languages and build tools. Also build environments in codebuild to use your own build tools. Codebuild scales automatically to meet the peak build requests.

In this post, you will get to know how to do continuous cloning of codecommit repo in multiple regions using codebuild and codepipeline. Here I have created codecommit repo, codebuild, codepipeline and iam role with required permission policies.

Architecture Overview

Image description
The architecture diagram shows the overall deployment architecture with data flow, aws codecommit repo, aws codebuild, iam role and aws codepipeline.

Solution overview

The blog post consist of the following phases:

  1. Create of CodeCommit Repo, CodeBuild, CodePipeline and IAM Role
  2. Output as Source CodeCommit Repo Branches with Files to Destination CodeCommit Repo

Phase 1: Create of CodeCommit Repo, CodeBuild, CodePipeline and IAM Role

  1. Open the CodeCommit console and create a repository in two regions(N.Virginia and Oregon). Also create CodeBuild with clone script of clone and CodePipeline with commit and build stage. For permission on build, assign permission of commit repo of both region with git pull and push on build role. Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Phase 2: Output as Source CodeCommit Repo Branches with Files to Destination CodeCommit Repo

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Image description

Clean-up

Delete CodeCommit Repo, CodeBuild Project, CodePipeline, IAM Role and CloudWatch Log Group.

Pricing

I review the pricing and estimated cost of this example.

Cost of CodeBuild = Free Tier - 100 build minutes on build.general1.small = $0.0

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

Cost of CloudWatch = First 5GB per month of log data ingested is free = $0.0

Total Cost = $0.0

Summary

In this post, I showed “continuous cloning of codecommit repo in multiple regions using codebuild and codepipeline”.

For more details on AWS CodePipeline, Checkout Get started AWS CodePipeline, open the AWS CodePipeline console. To learn more, read the AWS CodePipeline documentation.

For more details on AWS CodeBuild, Checkout Get started AWS CodeBuild, open the AWS CodeBuild console. To learn more, read the AWS CodeBuild documentation.

Thanks for reading!

Connect with me: Linkedin
Image description

Top comments (0)