Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
AWS Automation Cookbook

You're reading from   AWS Automation Cookbook Continuous Integration and Continuous Deployment using AWS services

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788394925
Length 388 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
Nikit Swaraj Nikit Swaraj
Author Profile Icon Nikit Swaraj
Nikit Swaraj
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Using AWS CodeCommit 2. Building an Application using CodeBuild FREE CHAPTER 3. Deploying Application using CodeDeploy & CodePipeline 4. Building Scalable and Fault-Tolerant CI/CD Pipeline 5. Understanding Microservices and ECS 6. Continuous Deployment to ECS Using Developer Tools and CloudFormation 7. IaC Using CloudFormation and Ansible 8. Automating AWS Resource Control Using AWS Lambda 9. Microservice Applications in Kubernetes Using Jenkins Pipeline 2.0 10. Best Practices and Troubleshooting Tips

Migrating a Git repository to AWS CodeCommit

As a developer, it's highly possible that we have our code in a GitHub account. So, we will see the migration of a GitHub repository to AWS CodeCommit. Customers often need to replicate commits from one repository to another to support disaster recovery or cross-region CI/CD pipelines. AWS CodeCommit has lots of flexibility when it comes to AWS developer services, such as CodeBuild, CodeDeploy, and CodeStar. Most companies nowadays will think to migrate from those repositories to AWS CodeCommit:

How to do it...

The following are the steps for migrating a project or repository hosted on another Git repository to AWS CodeCommit:

  1. Firstly, we have to create a CodeCommit repository named HelloWorld (refer to the previous CodeCommit repository either using HTTPS or SSH).

  1. After creating a CodeCommit repository, clone it to the local machine. Since we are cloning the repository using an HTTPS connection, then we need to give the HTTPS credentials of username and password (you can refer to the previous recipe):
    root@awsstar:~# git clone https://git-codecommit.us-east-    1.amazonaws.com/v1/repos/HelloWorld
Cloning into 'HelloWorld'...
Username for 'https://git-codecommit.us-east-1.amazonaws.com': awsccuser-at-1xxxxxxxx39
Password for 'https://awsccuser-at-16xxxxxxx39@git-codecommit.us- east-1.amazonaws.com':
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

3. Now, clone a GitHub repository using --mirror into another new folder. Here we have a GitHub repository whose name is Docker-Compose-CI-CD, which will be cloned into a pre-existing empty folder precommit:

>
     root@awsstar:~# mkdir precommit
root@awsstar:~# git clone --mirror https://github.com/awsstar/Docker-Compose-CI-CD.git precommit
Cloning into bare repository 'precommit'...
remote: Counting objects: 36, done.
remote: Total 36 (delta 0), reused 0 (delta 0), pack-reused 36
Unpacking objects: 100% (36/36), done.
Checking connectivity... done.
  1. Go to the directory where you made the clone:
    root@awsstar:~# cd precommit/
  1. Run the git push command, specifying the URL and name of the destination AWS CodeCommit repository and the --all option:
    root@awsstar:~/precommit# git push https://git-codecommit.us-east-    1.amazonaws.com/v1/repos/HelloWorld --all
Username for 'https://git-codecommit.us-east-1.amazonaws.com': awsccuser-at-160384169139
Password for 'https://awsccuser-at-160384169139@git- codecommit.us- east-1.amazonaws.com':
Counting objects: 36, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (33/33), done.
Writing objects: 100% (36/36), 3.73 KiB | 0 bytes/s, done.
Total 36 (delta 17), reused 0 (delta 0)
To https://git-codecommit.us-east- 1.amazonaws.com/v1/repos/HelloWorld
* [new branch] master -> master
  1. Now, let's view the migrated files in AWS CodeCommit:

Here, we can see how easily we have migrated the project from GitHub to AWS CodeCommit.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime