How to simple mirroring your repository to AWS CodeCommit

Aditya Kristianto
4 min readSep 30, 2023

--

Do you know that you can mirror your git repository ? If you want to do backup or using external repository that already integrated with build pipeline. In this story, I will show you how to mirroring your Github Repository to AWS CodeCommit Repository. The step is very simple. Please read all the step below. Thanks …

What is AWS CodeCommit ?

AWS CodeCommit is a git repository that you can use for code repository just like Github, Gitlab, Bitbucket and etc. AWS CodeCommit offering private and public repository with support for Large File Storage too.

What the benefit using AWS CodeCommit ?

There is many integrated tool inside AWS CodeCommit that you can use. For example, with integration between AWS CodeCommit and AWS CodePipeline you can create and manage the build pipeline procedure. With using AWS CodeBuild the AWS will help you to handle the building proses, like compiling your project into executable app or docker image, and many more benefit that you can explore it later.

How to create AWS CodeCommit repository ?

  1. Login into your AWS Console.
  2. Type “codecommit” in your search bar.
  3. Click “CodeCommit” in Services List Menu.
  4. In CodeCommit Page, click “Create Repository” button.
  5. Fill the create repository form.
  6. Create repository step is finished.
Step 1–3 Login into your AWS Console and search “codecommit” in search bar.
Step 4 Click create repository button
Step 5 Fill the repository form
Step 5 Please add the tag (optional)
Step 5 You finished create repository step

The next step create ssh access from your local computer.

Open your terminal or command prompt and type :

ssh-keygen -t ed25519 -C "your_email@gmail.com"

Enter the location you want to save the key (example) :

/Users/aditya.kristianto/.ssh/id_rsa

Last Step is adding SSH key to your SSH config :

sudo nano ~/.ssh/config

Adding this config below to your SSH config :

Host git-codecommit.*.amazonaws.com
User <SSH Key ID>
IdentityFile ~/.ssh/id_rsa

How to know your SSH Key ID ?

  1. Type “IAM” in your AWS search bar.
  2. Click on your username.
  3. Click Tab security credentials.
  4. Scroll your page and click “Upload SSH Public Key” button.
  5. Fill the form with your SSH Public Key from local computer.
  6. Click “Upload SSH public key” button.
  7. Finished and you get the information of your SSH Key ID.
Step 1 Type iam in search bar
Step 2 Clik on your username
Step 3 Click Tab security credentials
Step 4 Scroll page and click upload ssh public key
Step 5 Insert your ssh public key
Step 7 Finished and get the SSH Key ID

How to mirroring your repository to AWS CodeCommit ?

In your terminal and inside repository directory, please type :

git push --mirror ssh://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/MyRustApp

This is the result of git push mirroring command :

Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (10/10), 9.25 KiB | 4.63 MiB/s, done.
Total 10 (delta 0), reused 3 (delta 0), pack-reused 0
remote: Validating objects: 100%
To ssh://git-codecommit.ap-northeast-1.amazonaws.com/v1/repos/MyRustApp
* [new branch] main -> main
* [new reference] origin/HEAD -> origin/HEAD
* [new reference] origin/main -> origin/main

Next, you can check your code inside AWS CodeCommit menu inside AWS Console.

The information code here the file already finished mirroring.
Process to check the commit history

Finally, we have finished mirrong to AWS CodeCommit.

Originally published on Sept 26, 2023.

You are also welcome to contact me via LinkedIn or any collaboration is more than welcome.

LinkedIn : https://www.linkedin.com/in/aditya-kristianto/

Dev Community : https://dev.to/aditya_kristianto

--

--

Aditya Kristianto
Aditya Kristianto

Written by Aditya Kristianto

I am a Head of Technology, Technology Analyst & Solution Architect working at MNC Portal Indonesia and help companies in their digital transformation journey.

No responses yet