aws-cli Setup Codecommit for git command line


Example

AWS Codecommit can be used as storage for private GIT repositories. The setup involves a few steps, assuming you have a valid AWS account already.

  1. Sign up for AWS Codecommit. Currently only region us-east-1 is available.
  2. Create a IAM user who will have access to the repositories, eg codecommit-user
  3. Attach permission role AWSCodeCommitFullAccess to this user
  4. Create a new Access Key for this user and note key id and secret code
  5. Now go ahead and create a AWS Configuration profile on your local machine
$ aws configure --profile codecommit-user

In the next step we associate the aws command with git as the credential helper with the following commands:

$ git config --global credential.helper \
    '!aws --profile codecommit-user codecommit credential-helper $@'
$ git config --global credential.UseHttpPath true

You can verify or edit this setup afterwards:

$ git config --global --edit

You should note a section:

[credential]
    helper = !aws --profile codecommit-user codecommit credential-helper $@
    UseHttpPath = true

Now you can use git from the command line as usual.