how to setup AWS code commit repository3 min read

Prabhin Prabharkaran Administrator
DevOps Engineer

He is a Technical professional. He is a person who loves to share tricks and tips on the Internet. He Posts what he does!

follow me

Hi All, This document deals with how to setup code commit repository.
AWS code commit is a fully managed service that hosts a secure private git repository. Code commit is a version control system like GitHub, gitlab, subversion.
Code commits support to store any format of files such as application source code, application binary, or documents. Code commit doesn’t have any file format restriction.
Code commit allows you to work collaboratively with your team.
In terms of pricing, aws code commits charge $0 for the first five users for the unlimited repository, 10000 requests per month.
Migration from any git-based repository is very easy and straight forward to code commit.
Since code commit is a fully managed service by aws, it’s highly scalable. There are a lot of companies that put their efforts into managing and maintain their source control system. Using code commit eliminates all these efforts and let you save time, the effort of system engineers.
Comparing to security aws provided 4 built-in IAM policies let cloud admin assign for the users. Even you can create custom policies that apt your environment.
Code commit can be integrated with other third-party and aws code services.

Let’s start the creation of the first repository

Step 1: Log in to aws management console and select code commit from the services list.

Step 2: Click on the create repository.

Enter the required repository name and description repository.

Enabled codeguru if required, this option is not mandatory this enables code guru service to look into your code and provide some quality, security improvements that can be improved on your source code.

Click on create.

step 3: Now Goto IAM service section and select the user. Click on the permission tab and attach the relevant code commit built-in policy. In my case, I’m attaching the codecommitPowerUser policy.

You can attach any of these policies based on your requirement. Check out each policy description if it meets your requirements.

Security is something that should be taken care of by the cloud administrator to whom what kind of access to be given.

 

if you want a video of this document click on the below video URL.

step 4: upload your ssh public key to the IAM user.
The system which I’m using Linux, so I’m option access the code commit using ssh rather HTTP. if you prefer accessing HTTP create a username and password for your IAM user from the security credentials tab.
Note down the HTTP username and password if you are establishing HTTP based connection to the repository.


For ssh, generate ssh private and public key for your system. If not generate use the below command, or else ignore below step

ssh-keygen 

<Enter>
<Enter>

cat ~/.ssh/id_rsa.pub
copy this upload in the IAM security credentials upload-ssh public section.

Note down the ssh-key ID

Step 5: Create a config file.

vi ~/.ssh/config
Host git-codecommit.*.amazonaws.com
User Your-IAM-SSH-Key-ID-Here
IdentityFile ~/.ssh/id_rsa

Replace the SSH-key-ID from the above and identity file path if there is any change.

Step 6: Now lets clone the repository fist time.
Get your repository clone URL from the code commit page.
Code commit provide sets to take for each operating system (Windows, Linux, and macOS)


git clone ssh://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/project1
Cloning into 'project1'...
Warning: Permanently added the RSA host key for IP address '54.240.227.194' to the list of known hosts.
warning: You appear to have cloned an empty repository.

Step 7: let’s push some files.

cd project1
touch es-delete.yaml
git add .
git commit -a -m "test push"
git push

© 2020, Techrunnr. All rights reserved.

#1
#2
#3
Questions Answered
Articles Written
Overall Points

Related posts

Leave a Reply