running git clone against AWS CodeCommits gets me

2020-05-20 08:31发布

My local laptop is a Mac.

  1. The ssh key is configured properly. This is the content of ~/.ssh/config

    Host barthea Hostname git-codecommit.us-east-1.amazonaws.com User AVVVVVVVVVVVVVVVVVQ IdentityFile ~/.ssh/aws-aws.pem

Running ssh barthea gets me

`You have successfully authenticated over SSH. You can use Git to interact with AWS CodeCommit. Interactive shells are not supported.Connection to git-codecommit.us-east-1.amazonaws.com closed by remote host.

` 2. I created an IAM user bruce666 complete with password and access keys, made this user part of the "team" group.Then I created a policy that includes "AWSCodeCommitPowerUsers" and assigned this policy to "team". And finally assigned bruce666 to "team". At this point, bruce666 can access any repo in CodeCommit through the management console.

  1. I ran aws config --profile bruce666, fed in his access and secret key, his region and specified the format at json. At this point, I was able to create the rekha repo in CodeCommmit by running aws codecommit get-repository --repository-name rekha --profile bruce666

  2. I can create a couple of dummy files, run git init, git add . , git commit -m "1", git add origin https://git-gitcode.amzonaws.com/repos/v1/rekha , git push -u origin master And that operation will be successful.

  3. However, when I run git clone ssh://git-gitcode.amazonaws.com/repos/v1/rekha , I get "fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/barthia/': The requested URL returned error: 403" What gives?

9条回答
看我几分像从前
2楼-- · 2020-05-20 09:01

fatal: unable to access 'https://git-codecommit.yourregion.amazonaws.com/v1/yourrepositoryname/': The requested URL returned error: 403

It occurs due to below regions

  1. Make sure your user has codecommitfullaccess policy attached.
  2. make sure your default region in local aws cli configuration and region in which repository created are same. If not reset the default region in aws cli command as below

aws configure

  1. make sure if repository present there.
查看更多
【Aperson】
3楼-- · 2020-05-20 09:01

After running below commands, I had to add the below mentioned policy to my IAM user to solve this problem. refrence

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

Policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "codecommit:*"
            ],
            "Resource": "*"
        }
    ]
}
查看更多
\"骚年 ilove
4楼-- · 2020-05-20 09:05

For me the root cause of getting the error was that no matter which version of git I was using on OSX, GIT was always picking up the credential.helper config of using osxkeychain from the file:

/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig

Getting rid of this solved the problem for me and has not broken anything.

查看更多
登录 后发表回答