Get a private repository from AWS codecommit using HTTPS GRC
Asked Answered
V

1

6

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?

Volotta answered 21/10, 2021 at 18:37 Comment(2)
what is your motivation for using the http-grc protocol? have you actually tried with a .git at the end of the repo-url as suggested in the other question's answers? (for me it works either way, the .git is nor necessary). git config --global url.xxx seems like a mistake, because why would you want this setting for all repos / pprojects?Erlindaerline
In my company we use https-grc for security reasons instead of SSH. Yes, I'm trying with .git at the end: go get -x git-codecommit.us-west-2.amazonaws.com/my-module.git. The git config --global seems to be necessary to get repos not using standard HTTPS protocol as I read in another sources. In fact, I can't do go get codecommit::us-west-2://my-module because go get command doesn't allow to use characters like ":"Volotta
V
5

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
Volotta answered 26/10, 2021 at 8:7 Comment(1)
you are a saint. Thank you that helped me a lot!Cordey

© 2022 - 2024 — McMap. All rights reserved.