bluenowhere
bluenowhere

Reputation: 2733

Failed to connect SourceTree to AWS CodeCommit

I'm using Atlassian's SourceTree to work with git on Mac OS, and choose AWS CodeCommit as the remote hosting server.

Following these steps for HTTPs connection between AWS and my local repo,

here's how my git config --global --edit looks like:

enter image description here

Then try to clone a created empty repo from AWS to SourceTree: enter image description here

And I get error printed out:

abort: HTTP Error 403: Forbidden aws --profile default codecommit credential-helper $@ get: aws: command not found fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-git-repo/': The requested URL returned error: 403

UPDATE

Tried the answer provided by @Steffen Opel and got more like:

enter image description here

Did I miss anything?

Upvotes: 5

Views: 12217

Answers (4)

George Dima
George Dima

Reputation: 2787

if you installed aws cli from homebrew (instead of pkg) , and you have it in .gitconfig credential without path you can do this simple fix, link to the pkg install path, tested and working on Sourctree.

sudo ln -s /opt/homebrew/bin/aws /usr/local/bin/aws

Upvotes: 0

ebandersen
ebandersen

Reputation: 2352

I just found this answer here (https://geekprotem.com/2015/07/10/aws-codecommit-with-sourcetree/)

After following the setup steps for AWS CLI on Amazon's website, the final step to get this to work was editing my repository's config file in SourceTree to include the following:

[credential]
helper = /usr/local/bin/aws codecommit credential-helper $@
UseHttpPath = true

Upvotes: 7

Steffen Opel
Steffen Opel

Reputation: 64741

I have not tested this, but given AWS CodeCommit facilitates a credential helper too and the error beingcommand not found, I would assume you are affected by the same issue outlined in the SourceTree Knowledge Base article Credential helpers "git: 'credential-osxkeychain' is not a git command. See 'git --help'.":

The error [...] occurs because Git calls this helper and cannot find it meaning it has been defined and yet not found on the PATH. In terms of SourceTree as of version 1.6.3 this is nothing to worry about. There's two ways to stop this from happening.

  1. Not recommended, but if you're solely using SourceTree for everything you could remove the 'credential' setting from the /usr/local/git/etc/gitconfig config. This is a quick and easy method, but it does mean operations at the terminal may not be able to authenticate.
  2. Recommended, create a symlink between git-credential-osxkeychain in the SourceTree app resources and your local git install.

    ln -s /usr/local/git/bin/git-credential-osxkeychain /Applications/SourceTree.app/Contents/Resources/git_local/bin/git-credential-osxkeychain

Of course, since AWS CodeCommit requires the credential helper to be in place, only solution 2 is conceptually applicable for your scenario and you need to adjust the link source and targets as appropriate for the CodeCommit credential helper.

Upvotes: 1

Mircea
Mircea

Reputation: 10566

seems about right. the "command not found" is the problem. I would say that aws is not in the path, and when the credential helper tries to help it cannot find it. double check it's in the path by doing which aws

Upvotes: 1

Related Questions