How To Create An AWS CodeCommit Repository
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed different DevOps tools available in AWS.
https://cloudaffaire.com/what-are-different-devops-tools-available-in-aws/
In this blog post, we will start with our 1st AWS DevOps tool AWS CodeCommit and will discuss how to create an AWS CodeCommit repository using AWS CLI.
What Is AWS CodeCommit:
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. You can compare CodeCommit service with GitHub, GitLab, Bitbucket or any git-based hosting solution.
What Is A Repository:
In version control systems (for example, git), a repository is a data structure that stores metadata for a set of files or directory structure. Some of the metadata that a repository contains includes, among other things:
- A historical record of changes in the repository.
- A set of commit objects.
- A set of references to commit objects called heads.
How To Create An AWS CodeCommit Repository:
Requirements:
AWS CLI installed and configured. You can follow the below blog post to install and configure AWS CLI.
https://cloudaffaire.com/how-to-install-aws-cli/
https://cloudaffaire.com/how-to-configure-aws-cli/
Git installed and configured.
https://cloudaffaire.com/category/devops/git/
Step 1: Create a new AWS CodeCommit repository using AWS CLI.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
################################################ ## How To Create An AWS CodeCommit Repository ## ################################################ ## I am using a Linux shell to execute AWS CLI commands ## create a directory for this demo mkdir codecmit && cd codecmit ## create a new repository aws codecommit create-repository \ --repository-name "testrepo" \ --repository-description "testrepo" \ --tags "Key=Name,Value=MYAPP" |
Step 2: Get details for your newly created CodeCommit repository.
1 2 3 4 5 6 |
## list all repositories in a region aws codecommit list-repositories ## get repository details aws codecommit get-repository \ --repository-name "testrepo" |
Step 3: Update CodeCommit repository name and description using AWS CLI.
1 2 3 4 5 6 7 8 9 |
## update repository name aws codecommit update-repository-name \ --old-name "testrepo" \ --new-name "my_aws_repo" ## update repository description aws codecommit update-repository-description \ --repository-name "my_aws_repo" \ --repository-description "CloudAffaire test repository for codecommit demo" |
Our 1st AWS CodeCommit repository created and updated successfully.
Step 4: Try to clone your AWS CodeCommit repository.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
## try to clone your repository GIT_CLONE_HTTP_URL=$(aws codecommit get-repository \ --repository-name "my_aws_repo" \ --query 'repositoryMetadata.cloneUrlHttp' \ --output text) && GIT_CLONE_SSH_URL=$(aws codecommit get-repository \ --repository-name "my_aws_repo" \ --query 'repositoryMetadata.cloneUrlSsh' \ --output text) #install git if not already installed #using http (will ask for a password, click cancel) git clone $GIT_CLONE_HTTP_URL #using ssh (type 'yes' when prompted, will fail) git clone $GIT_CLONE_SSH_URL #both methods will fail as we have not setup #any access for our repository which we will #do in our next blog post |
Note: In order to access your AWS CodeCommit repository remotely, you have to 1st configure the access. Since we have not configured any access method for our CodeCommit repository, you will not be able to clone your repo. There are several ways to access an AWS CodeCommit repository which we will cover in the next blog post.
Step 5: Cleanup (do not delete if you want to continue with the series)
1 2 3 4 5 6 |
## delete your repository (do not delete if you want to continue with the series) aws codecommit delete-repository \ --repository-name "my_aws_repo" ## delete the directory for this demo cd .. && rm -rf codecmit |
Hope you have enjoyed this blog post. To get more details on AWS CodeCommit, please refer below AWS documentation
https://docs.aws.amazon.com/codecommit/latest/userguide/welcome.html
CodeCommit is a Git-based version control system and you need to have a basic understanding of Git in order to work with CodeCommit. You can follow the below link to get a basic understanding of Git.
https://cloudaffaire.com/category/devops/git/