Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clone AWS codecommit repo via HTTP

I have set 2 repositories in AWS Codecommit and using before SourceTree from Windows, setting up access via HTTP protocol was and everything was working fine.

Right not I am migrating the development of a project on a machine where I do have installed ubuntu and where I choose to use gitkraken.

I was able to git clone in a folder where my user has read and write access(my user) via Terminal, so isn't permission related in Ubuntu, where after git clone "aws repo url" I was prompt asking for the username for the IAM and password(the one created at AWS IAM console).

I can of course open that repo folder from gitkraken and see even all the remote branch and all the history, but once I do for example pull from gitkraken it failed as "access" denied. I cannot also clone the same or another repo from Gitkraken. So seems I do have to configure my credentials in gitkraken but not sure where that should be done. This official doc does not say much.

like image 553
Carmine Tambascia Avatar asked May 15 '18 15:05

Carmine Tambascia


2 Answers

I actually found that I was able to connect, and previously I was failing because not following some steps quite hide in the AWS Codecommit docs:

I am not sure if giving the following at prompt are necessary steps, but I guess they do not hurt:

At terminal provide the following:

aws configure

you will be prompt to provide:

AWS Access Key ID

AWS Secret Access Key

Default region name

Default output format

Till here I do recommend to provide the above

After on clone "your https AWS address" your_repo_name, you are prompted to provide an username and a password. Unfortunately for both my root account and my IAM account(with correct rules policy) I got 403 error.

What was successful, without provide additional credential was to execute at terminal the following:

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

then simply:

clone https://your_url_code your_repo_name for HTTPS connection from AWS Codecommit console

For more detailed instruction refer to the official docs

This worked for me.

like image 60
Carmine Tambascia Avatar answered Sep 30 '22 06:09

Carmine Tambascia


You can try to setup a SSH connection following this docs: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-ssh-unixes.html.

After that, open the repository with Gitkraken. When you try to pull or push, Gitkrake will ask you for credentials. Use the ssh credentials created on the previous step.

If Gitkraken fails again, check the file .git/config inside your local copy of the repository. I've noticed that the url created was incorrect, so check that the generated url matches the following pattern:

[remote "origin"]
url = ssh://<Your-SSH-Key-ID>@git-codecommit.<region>.amazonaws.com/v1/repos/<repo-name>
fetch = +refs/heads/*:refs/remotes/origin/*
like image 25
Ronald Poillot Cartes Avatar answered Sep 30 '22 08:09

Ronald Poillot Cartes