Creating A Repository in AWS Git, a.k.a. CodeCommit (AWS)

EC2 Amazon Linux AMI Banner

AWS has its own Git repository system called CodeCommit. Here is what AWS have to say about it:

“CodeCommit is a secure, highly scalable, managed source control service that hosts private Git repositories. CodeCommit eliminates the need for you to manage your own source control system or worry about scaling its infrastructure. You can use CodeCommit to store anything from code to binaries. It supports the standard functionality of Git, so it works seamlessly with your existing Git-based tools.”

So basically it is AWS’ answer to GitHub. As I am currently getting to grips with AWS I thought it was worth taking a look at CodeCommit, which is free for the first 5 (five) active users. This free tier includes unlimited repositories, 50GB per month of storage and 10,000 Git requests per month.

An “active user” is any unique AWS identity (IAM user/role, federated user or root account). So my CodeCommit activity will probably be limited to 2 (two) active users – my root account and my IAM user. After the first 5 active users AWS starts to charge $1 per month per additional active users, who then get unlimited repositories, 10GB-month of storage and 2,000 Git requests per month.

Unused storage / Git requests do not accumulate, if the limits are met then AWS starts to charge an addition $0.06 per GB per month and $0.001 per Git request.

CodeCommit Repository Names

AWS CodeCommit repository names can contain up to 100 alphanumeric characters and can contain dashes and underscore characters. The name cannot end with the suffix .git.

Creating A Repository (AWS Web Management Console)

Open up https://console.aws.amazon.com/codesuite/codecommit/home, check your region (top right of the screen) is correct and press “Create Repository”.

geektechstuff_aws_codecommit_1
AWS CodeCommit Repositories Screen

This is also the screen that allows you to view, delete and manage your CodeCommit repositories.

CodeCommit will ask you to name the repository and to add a description (optional, but recommended). As always I recommend that you add some sensible tags to the resource as well to make it easier to track / report on later.

AWS CodeCommit Create Repository screen
AWS CodeCommit Create Repository screen

Pressing “Create” should hopefully result in a success screen.

AWS CodeCommit Success
AWS CodeCommit Success

And with the repository successfully created we can use the AWS web management system to add / delete files and create new branches.

AWS CodeCommit Repository Screen
AWS CodeCommit Repository Screen

 

Creating A Repository (AWS CLI)

I like the AWS web management system, however I much prefer the AWS CLI. Creating a repository via the AWS CLI requires the following:

aws codecommit create-repository –repository-name geektechstuff_demo_2

aws codecommit create-repository --repository-name geektechstuff_demo_2
aws codecommit create-repository –repository-name geektechstuff_demo_2

Replacing “geektechstuff_demo_2” with the name you want for your repository. Although this creates a repository I would recommend using the following command instead:

aws codecommit create-repository –repository-name geektechstuff_demo_3 –repository-description “a demo repository from geektechstuff” –tags Purpose=demo

aws codecommit create-repository --repository-name geektechstuff_demo_3 --repository-description "a demo repository from geektechstuff" --tags Purpose=demo
aws codecommit create-repository –repository-name geektechstuff_demo_3 –repository-description “a demo repository from geektechstuff” –tags Purpose=demo

This creates a repository with a name, description and a tag. I have coloured the text red that is text I have created.

Viewing Repositories

As mentioned earlier, repositories can be created, viewed, edited and deleted via https://console.aws.amazon.com/codesuite/codecommit/home. As the below image shows, the screen will show all repositories linked to the AWS account including those created via the AWS CLI.

geektechstuff_aws_codecommit_7
AWS repositories screen

From the AWS CLI a single repository’s details can be viewed with the command:

aws codecommit get-repository –repository-name geektechstuff_demo

Replacing “geektechstuff_demo” with the repository’s name.

aws codecommit get-repository --repository-name geektechstuff_demo
aws codecommit get-repository –repository-name geektechstuff_demo

To list all repositories linked to the AWS account use:

aws codecommit list-repositories

aws codecommit list-repositories
aws codecommit list-repositories

Deleting Respositories

All done with a repository? It can be deleted via the AWS web management console or it can be done with the AWS CLI:

aws codecommit delete-repository –repository-name geektechstuff_demo

Replacing “geektechstuff_demo” with the repository’s name.

aws codecommit delete-repository --repository-name geektechstuff_demo
aws codecommit delete-repository –repository-name geektechstuff_demo

 

 

Posted in AWS

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.