AWS CodeCommit Tutorial

Home » Generic » AWS CodeCommit Tutorial
AWS CodeCommit

AWS CodeCommit is a source code storage and version code service by Amazon. AWS CodeCommit allows your teams to manage and collaborate with the code efficiently and securely. It is a fully managed service, so you do not need to worry about the underlying infrastructure, security or maintenance. You can store the source code, documents, binary files, assets, etc. AWS CodeCommit provides excellent integration with other AWS services, especially CI/CD services.

Today, we will discuss the different features of AWS CodeCommit. In this AWS CodeCommit tutorial, we will go through the pricing model of CodeCommit, and then will compare CodeCommit with other source code platforms like GitHub and Bitbucket. Let’s start with the core features of AWS CodeCommit.

Core Features of AWS CodeCommit

Below, you’ll find the essential features of CodeCommit:

  • Fully Managed Service

CodeCommit is a fully managed service by Amazon, which means you do not need to worry about maintaining updates or managing the underlying hardware/software. AWS will take care of everything, including the high availability and durability of the service.

  • Source Code Security

The code residing in AWS CodeCommit repositories is pretty secure as it is encrypted at rest by AWS. The access to code is only through proper authentication and authorization of AWS’s built-in IAM users.

  • Built-in Scalability

It has built-in scalability – so based on the number of repositories or code files, it can automatically scale without any manual intervention.

  • High Collaboration with Code

CodeCommit allows you to collaborate on the code efficiently. Users can review, comment and update each other’s code in a highly collaborative manner.

  • Strong Integrations

CodeCommit has strong integrations with other AWS services. For example, you can easily integrate it with CodeBuild, AWS SNS, etc. You can also integrate AWS CodeCommit with third-party services.

  • Easy Migration

It is very easy to migrate any Git-based repository to AWS CodeCommit.

How to use AWS CodeCommit

There are three ways you can use AWS CodeCommit:

  1. AWS Console: You can use the web-based console to perform different actions like creating a repository, creating a branch, etc.
  2. Git commands: Use the standard Git commands to manage your code.
  3. AWS CLI commands: Use the AWS CLI commands to manage your code, branches, and pull requests.

The below diagram illustrates how the AWS CodeCommit service works through its CLI/console and the actual service.

How to run AWS CodeCommit Commands

Running CodeCommit commands is simple. Download and install the standard AWS CLI. After that, you just need to execute the command “AWS Configure” to configure the CLI with your secret key and access key for the purpose of authentication and authorization. Then you can use the AWS CodeCommit-specific CLI commands in the command prompt. Here are some of the basic commands:

  • AWS CodeCommit Shows the usage of CLI along with different options
  • AWS CodeCommit command-name help Shows help of a particular command of AWS CLI
  • Create-repository Creates the repository
  • List-repositories Shows the list of repositories

Features & Commands

AWS CodeCommit is based on the standard workflow of Git. The concepts of the pull request, merging, branch switching, stash, reset, restore, etc. are all the same. Let’s go through some of the powerful features of CodeCommit one by one.

Repository

  • By using tags, you can set up notifications on different actions related to the repository like merging PR, commenting on code, etc.
  • You can share your repository with other users.
  • You can create triggers based on different actions e.g. push code to a lambda function if a code pull request is generated. The trigger can act as a bridge between CodeCommit and other integrations like CodeBuild or Lambda.
  • You can link your CodeCommit repository with AWS CodeGuru reviewer – an automated code review service from Amazon.
  • You can push your code to different repositories simultaneously.
  • To fetch a remote Git repository to your local machine, execute the command “git clone
  • To push code changes from your local repository to the CodeCommit repository, run ‘git push <remote-name> <branch-name>’.
  • To fetch changes from the remote CodeCommit repository to the local repo, execute ‘git pull <remote-name> <branch-name>’.
  • You can sync GitHub Actions to mirror and sync with AWS CodeCommit using e.g. this tool https://github.com/marketplace/actions/github-to-aws-codecommit-sync

Pull requests

A pull request involves two branches. One is the source branch which contains the new changes to be reviewed. The other branch is the destination branch to which the changes need to be merged. Following are some of the essential actions you can take with pull requests through CodeCommit:

  • The pull request will show the difference between tip of the source branch and the last commit on the destination branch when the pull request is inititated.
  • You can set up notifications or your repository so that the users can be informed about the pull request
  • You can use the CodeCommit web console to perform the following actions upon a pull request:
    • Close the pull request without merging it into the parent branch
    • You can resolve any conflicts in the pull request
    • Close and merge using one of the merge strategies
  • You can create and associate approval rule templates with your repository. As a result, approval rules are automatically created for different pull requests – improving your code quality.
  • You can link AWS IAM users with your repository users, which will make it easier for you to track code changes.
  • Not only can IAM users use Git credentials for access to the repository, but other users as well – including federated access users – can use pull requests.

Commit and branch

  • You can manage commits and comments on the commits
  • You can manage Git tags
  • You can limit pushes and merges to branches in CodeCommit
  • Compare and merge branches
  • If you are using AWS CLI, you can use the command “create-commit” to create a new commit for the branch
  • You can use the standard Git commands as well as the AWS web console to manage your commits and branches
  • To view the history of merges and branches, you can use AWS Commit Visualizer

Migration

  • You can migrate your Git repository to AWS CodeCommit in a number of ways:
    • Clone it
    • Mirror it
    • Migrate all code
    • Migrate just some of the branches
    • Migrate just un-versioned code to CodeCommit
  • For a large repository, you can perform migration in chunks.
  • CodeCommit supports not just Git but TFS and perforce as well

Pricing

Find below the pricing table for AWS CodeCommit.

Some Quota limits apply such as:

  • 1,000 repositories by default (up to 25,000 after request).
  • A single blob in a repository cannot exceed 2 GB in size.
  • The total size of your files in a single commit cannot exceed 20 MB.
  • An individual file size cannot exceed 6 MB.

CodeCommit vs GitHub

  • CodeCommit is the best choice if most of your application components are already deployed on AWS.
  • If your repositories are mostly public instead of private then GitHub is the better option because AWS CodeCommit does not have any native option for creating a public repository. You can share your CodeCommit private repository with other users though.
  • The overall CI/CD workflow is easier to manage in GitHub especially using GitHub actions. To achieve the same through CodeCommit, you will need to spend more time in the configuration
  • Managing permissions in CodeCommit is challenging because most of the time you will need to write custom json/yaml policies.
  • If you are using CodeCommit, you are tied to a particular cloud vendor. In case of GitHub, you are vendor neutral so you can easily switch your cloud provider without worrying about repo migration.

CodeCommit vs Bitbucket

  • Bitbucket gives you unlimited free private repositories (including the free version). If you are a freelancer and want to avoid sharing the code repositories of your client, then Bitbucket is a great choice.
  • Bitbucket has excellent integration with Jira and Trello. If you are already using these tools for project management then Bitbucket is an excellent choice.
  • AWS CodeCommit is a better choice if you want to use AWS CI/CD services because CodeCommit has strong integration with other AWS services.
  • If you have a regulatory or compliance which requires you to store your source code in your own data centers then Bitbucket allows for on-premise installation too. AWS CodeCommit on the other hand is always on cloud.

Learn how to Master the Cloud

AWS Training – Our popular AWS training will maximize your chances of passing your AWS certification the first time.
Membership – For unlimited access to our entire cloud training catalog, enroll in our monthly or annual membership program.
Challenge Labs – Build hands-on cloud skills in a secure sandbox environment. Learn, build, test and fail forward without risking unexpected cloud bills.

Responses

Your email address will not be published.