The right way to Setup Credential Helper for AWS CodeCommit

AWS CodeCommit is a git code repository service by Amazon Internet Companies.

You’ll want to clone your repository and setup your remotes utilizing credential helper.

Step 1 – Setup Credential Helper#

git config --global credential.helper '!aws codecommit credential-helper [email protected]'
git config --global credential.UseHttpPath true

This can write to your native person’s ~/.gitconfig, and the file will look one thing like:

[credential]    
    helper = !aws --profile CodeCommitProfile codecommit credential-helper [email protected]
    UseHttpPath = true

You may edit this file by working the next git command:

git config --global --edit

Step 2 – Non-compulsory – If utilizing MacOS#

By connecting to the CodeCommit repository with HTTPS, the entry is by default momentary, and connections will begin failing after about quarter-hour.

To repair this, it’s worthwhile to:

  • Set up a model of Git that doesn’t use the keychain by default.
  • Configure the Keychain Entry utility to not present credentials for CodeCommit repositories.
  1. Open the Keychain Entry utility. (You need to use Finder to find it.)
  2. Seek for git-codecommit.us-east-2.amazonaws.com. Spotlight the row, open the context menu or right-click it, after which select Get Information.
  3. Select the Entry Management tab.
  4. In Verify earlier than permitting entry, select git-credential-osxkeychain, after which select the minus signal to take away it from the record.

After you take away git-credential-osxkeychain from the record, you see a pop-up message everytime you run a Git command. Select Deny to proceed. When you discover the pop-ups too disruptive, listed below are another choices:

Step 3 – Git Clone the Repository#

At this stage now you can git clone the repository in CodeCommit.

Open the CodeCommit console at https://console.aws.amazon.com/codesuite/codecommit/residence.

Discover the repository you need to connect with from the record and select it. Select Clone URL, after which select the protocol you need to use when cloning or connecting to the repository. This copies the clone URL.

git clone https://git-codecommit.us-east-2.amazonaws.com/v1/repos/your-repo your-repo-directory

Extra notes#

In case you are cloning as a part of a profile identify in your ~/.aws/config, then you will have to set the AWS_PROFILE atmosphere variable as follows:

export AWS_PROFILE = "<profile_name"