Home > Back-end >  Get a private repository from AWS codecommit using HTTPS GRC
Get a private repository from AWS codecommit using HTTPS GRC

Time:10-27

I'm trying to import a module located in AWS codecommit. To clone the repository I'm using HTTPS GRC (Git Remote Codecommit) method, which uses Google Suite credentials to access AWS console.

The command I use to clone the repository is:

git clone codecommit::us-west-2://my-module

The remote module's go.mod file contains this:

module git-codecommit.us-west-2.amazonaws.com/my-module.git

I tried to achieve my goal configuring Git like this:

git config --global url."codecommit::us-west-2://".insteadOf "https://git-codecommit.us-west-2.amazonaws.com/"

Setted GOPRIVATE:

go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com/my-module.git

And then getting the repository:

go get -x git-codecommit.us-west-2.amazonaws.com/my-module.git

but I get this output (and the execution gets stuck):

cd.
git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module

I would like to mention that when I execute the git ls-remote https://git-codecommit.us-west-2.amazonaws.com/my-module command manually I get the information of the branches and tags without problems.

I checked this topic but in that case SSH protocol is used instead of HTTP GRC. Maybe the only way to import a module from a private repository is via SSH?

CodePudding user response:

Finally found the solution:

Set Git credential helper:

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

Set GOPRIVATE env var:

go env -w GOPRIVATE=git-codecommit.us-west-2.amazonaws.com

In MacOS, disable keychain for Git:

Comment helper = osxkeychain in the file containing that value (run git config -l --show-origin | grep credential to find the target file)

Run go get:

go get git-codecommit.us-west-2.amazonaws.com/v1/repos/my-module.git
  • Related