AWS CodeCommit - Setup HTTPS Connection

Posted: | Last updated: | 2 minute read

Inception: Learn about AWS CodeCommit HTTPS connection types that will help you in connecting with `pull`, `push`, `branching`, etc git operation on CodeCommit from your local computer. This is another basic step towards setting up fully automated AWS Pipeline in DevOps.

To setup HTTPS connection with AWS CodeCommit, you need to create a repository and then an IAM User. Click here to Setup SSH connection with AWS CodeCommit repository.

Setup HTTPS connection pretty easy in AWS CodeCommit. Following are steps to setup it.

Create IAM Users/Groups

Follow below steps to create a IAM Group and User.

  • Create a IAM Group named developer.
  • Attach a Managed Policy AWSCodeCommitFullAccess to developer.
  • Create an IAM User with Programmatic access, and AWS Management Console access
  • Add this new User to the developer group.

Generate HTTPS Git credentials for AWS CodeCommit

Following are the steps to generate HTTPS Git credentials for AWS CodeCommit.

  1. Login to AWS Console and go to IAM
  2. Click on IAM User, you want to generate HTTPS credentials.
  3. Click on Security credential tab
  4. Go to HTTPS Git credentials for AWS CodeCommit, and click on Generate credentials button.
  5. It will generate credentials and show you User name, and Password
  6. Download the credentials and keep it safe.

Setup your repository

Now you will learn how to use these HTTPS credentials to upload your local code to AWS CodeCommit.

There might be 2 scenarios, either you might have created a new CodeCommit repository, which has nothing as of now or you are going to join a developers team in which there is already a CodeCommit repository and you want to clone that repository.

Both scenarios are similar except in first one you are going to make first commit.

Scenario #1

Follow below steps to setup connection to CodeCommit repository from scratch.

  1. You have created a empty CodeCommit repository, and HTTPS git credentials are generated.
  2. Go to CodeCommit repository, click on Clone URL, and then click on Clone HTTPS option to copy the URL
  3. Go to command line and type a command git clone HTTPS_GITHUB_URL and press enter.
  4. Enter the HTTPS credential’s Username and Password
  5. You must see Warning: You appear to have cloned an empty repository. and Checking connectivity… done. on successful connection.
  6. Now you have established HTTPS connection from your local machine to CodeCommit repository. You are ready to push some initial code to the repository.

Scenario #2

In this scenario, you have already a repository in AWS CodeCommit and you want to clone the repo and start contributing the code.

Follow below steps to setup connection to CodeCommit repository.

  1. You have existing repository on AWS CodeCommit, and you have generated HTTPS Git credentials for AWS CodeCommit for your IAM user.
  2. Go to AWS CodeCommit repository on AWS Console.
  3. Click on repository, you want to clone it locally.
  4. Click on Clone URL, and then click on Clone HTTPS.
  5. Go to command line and type a command git clone HTTPS_GITHUB_URL and press enter.
  6. Enter the HTTPS credential’s Username and Password.
  7. You will see that repository has been cloned and you are ready to make changes in code and push them back to repository.
Conclusion: You have set up HTTPS Connection from your local machine to AWS CodeCommit, and cloned the repository to your local machine. Now you are ready to develop the code, commit and push the changes into CodeCommit Repository. You can run all `git` from your local machine.