AWS Codecommit Tutorial – Beginners Guide

In a normal private environment , if you want to host your code using solutions like gitlab, Atlassian stash etc, you will need manage high availability and scalability for your production systems. AWS codecommit is a private managed source control system which is secure, highly scalable and scalable. It is git based and it works the same way like all other git based source control systems like github, stash etc. This allows easy migration of your code repositories to codecomiit and have the same work-flow you used to have. Moreover, codecommit provides out of the box encryption for your source codes which is at rest and in transit. If your applications are hosted in AWS, codecommit would be a good fit for all your source codes.

AWS Codecommit Tutorial

This aws codecommmit tutorial will guide you to get started with AWS codecommit service. To follow this tutorial, you need to have the latest AWS CLI installed on your system. If you do not have the CLI setup follow this link for the setup. It is always advisable to create an IAM user and attach a policy with required access to codecommit.

You Might Like: AWS account security tips

Creating a repository

Like you do in any source control system, the first step is to create a repository for your project. Use the following syntax for creating a repository in codecommit.

Once the command execution is successfull, it returns the output with the codecommit repo url for both ssh and http.

Authentication local git to codecommit

Next step is to configure your local git for authenticating againist codecommmit. So that you will have persmissions to clone, push and do all the remote repository related tasks. You can do that using the credential helper as shown below.

Common git config

Cloning the Repository

You can clone the remote codecommit repository to your local workstation using the normal git clone command and the repository url you got in the output section when you created the repository.

performing Common Git Funtions

Now you have an empty repository clonned from codecommit. You can perform all the normal git operations as you perform with any git based source control system as shown below.

Note: If you are using Ubuntu 14.04 as your workstation, you are likely to get a “gnutls_handshake() failed” error. You can rectify this error by following this solution. gnutls_handshake() failed solution

Creating a Branch

You can create a branch for your repository using “create-branch” attribute. For this you must pass the commit id to for the new branch to point to.You can get short hash of commit id’s using “git log” command. An example is shown below.

Once you get the commit id, use the following command to create a new branch. Replace the repository name, branch name and commit id accordingly.

List all Branches

You can list all the branches associated with a repository using “list-branches” as shown below.

Rename a Repository

A repository can be renamed using “update-repository-name” attribute.

Getting Repository Details

To get the information about more than one repository, you can run a batch-get-repositories attribute as shown below.

Deleting a Repository

“delete-repository” attribute is used with the cli to delete a repository.


Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.