AWS/Azure/OpenShift Version Control System (VSC)

How to Setup HTTPS users using Git credentials and Pushing Code to AWS CodeCommit

Screenshot-2022-03-20-at-20.37.16

If you want to create a connection to AWS CodeCommit repositories is by configuring Git credentials for CodeCommit in the IAM console. This credential can be used for HTTPS connections and can create access for you to push your code to AWS CodeCommit. These same credentials can be used with a third-party tool or IDE that supports HTTPS authentication that uses username and password. Kindly check these pages to read more on AWS: How to Deploy Dynamic Website to AWS EC2, Lear how to host Static Website and Versioning on AWS S3, How to deploy an Angular App to AWS S3, how to manage cost with AWS Budgets, and how to use AWS CodeCommit.

Now follow the below steps to set up an AWS account, IAM user, and access to CodeCommit.
image-40
IAM Users
  • On the Permissions tab, click Add Permissions.
image-41
Adding Permissions
  • In the Grant permissions page, select Attach existing policies directly and filter out and select AWSCodeCommitPowerUser. Then choose Next: Review to complete the policy addition.
image-42
Granting Permission

Installing Git

If you will be working with files, commits, and other access to CodeCommit repositories, you must install Git on your local machine. If you want to install Git go here. Here are some related guides: Practical Git use with markdown, how to install Git on macOS, and how to clone a repository and install software from GitHub.

Now let us Create Git credentials for HTTPS connections to CodeCommit. After installing Git, go ahead to create Git credentials for your IAM user in your IAM console.

  • Go back to the AWS Management Console and open the IAM console.
  • Make sure to sign in as the IAM user who will create and use the Git credentials to connect to CodeCommit.
  • In the IAM console select the IAM user from the list of users.
  • On the users summary page, click the Security Credentials tab
image-43
Setting Up Git Credentials
  • Scroll down and click HTTPS Git credentials for AWS CodeCommit, choose Generate.
image-45
HTTPS Git Credentials
image-46
Generate Credentials

Make sure you copy the user name and password that was generated by copying or downloading the CSV file to a safe location on your computer.

Now go to the CodeCommit console and clone the repository by following the below steps:

  • You can access CodeCommit console at https://console.aws.amazon.com/codesuite/codecommit/home.
  • Select the repository you want to connect to from the list of repositories. Next Choose Clone URL, and select the protocol you want to use when cloning or connecting to the repository.

Note: You will copy the HTTPS URL if you will be using Git credentials with your IAM user

  • You will copy the HTTPS (GRC) URL if you will be using the git-remote-codecommit command on your local computer.
  • You will copy the SSH URL if you will be using an SSH public/private key pair with your IAM user.

In this guide, we will be using HTTPS clone URL. Open a Git bash and run the git clone command with the HTTPS clone URL you copied to clone the repository.

For instance, if you want to clone a repository named techdirectarchive2 to a local repo named techdirectarchive_repo use this command below

git push https://git-codecommit.eu-west-3.amazonaws.com/v1/repos/techdirectarchive2 --all

You will need to supply the Git credentials you earlier saved in a location. The first time you connect, you are prompted for the user name and password for the repository.

image-47
Git Credential Manager

The same also applies if you want to push your local repo to the AWS commit repo. You need to make use of all required git commands and use this command in the final line.

 git push https://git-codecommit.eu-west-3.amazonaws.com/v1/repos/NameOfYourRepo --all
image-48
Git Credential Manager

Use the following git commands to move your code online

All the code has been successfully moved to AWS CodeCommit Repository.

image-52
Code finally pushed to AWS

I hope you found this blog post on How to Setup HTTPS users using Git credentials and Pushing Code to AWS CodeCommit interesting and helpful. In case you have any questions do not hesitate to ask in the comment section.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x