【问题标题】:Unable to clone AWS CodeCommit with IAM Role无法使用 IAM 角色克隆 AWS CodeCommit
【发布时间】:2016-07-04 08:27:56
【问题描述】:

我的 ec2 实例有以下设置,但没有运气。

还有a same issue on aws forum,但没有答案。

~/.gitconfig:

[credential]
        helper = !aws --region us-east-1 codecommit credential-helper $@
        UseHttpPath = true

EC2 实例的 IAM 角色政策:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "codecommit:*"
      ],
      "Resource": "*"
    }
  ]
}

然后下面的代码工作:

echo -e "protocol=https\npath=/v1/repos/my-repo\nhost=git-codecommit.us-east-1.amazonaws.com" | aws --region us-east-1 codecommit credential-helper get

但是,对于 git,它不会。

git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-repo
Cloning into 'my-repo'...
fatal: unable to access 'https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-repo/': The requested URL returned error: 403

有什么想法吗?

更新

经过一番调查,我发现附加的 IAM 角色无法进行 git 操作,但 IAM 用户工作正常。

| Type                               | list-repositories | credential-helper | git operation |
| IAM User with CodeCommitFullAccess | OK                | OK                | OK            |
| IAM Role with CodeCommitFullAccess | OK                | OK                | NG            |

尝试以下命令:

  • 列表存储库

    aws codecommit list-repositories

  • 凭证助手

    echo -e "protocol=http\npath=/v1/repos/my-repo\nhost=git-codecommit.us-east-1.amazonaws.com" | aws --region=us-east-1 codecommit credential-helper get

  • git操作

    git clone --config credential.helper='!aws --region=us-east-1 codecommit credential-helper $@' --config credential.UseHttpPath=true https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-repo

我的 awscli 版本如下:

$ aws --version
aws-cli/1.10.44 Python/2.7.5 Linux/3.10.0-327.10.1.el7.x86_64 botocore/1.4.34

更新2

我的 git 和 curl 版本如下:

$ git --version
git version 1.8.3.1
$ curl --version
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.19.1 Basic ECC zlib/1.2.7 libidn/1.28 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz

【问题讨论】:

  • 你使用的是什么操作系统?
  • 我使用的是 CentOS7。但我认为这不是问题。
  • 你用的是什么版本的git和curl?
  • @WadeMatveyenko 添加在帖子的最后。

标签: aws-codecommit


【解决方案1】:

您至少需要使用 curl 7.33 或更高版本。来自 CodeCommit 文档:

AWS CodeCommit requires curl 7.33 and later. However, there is a known issue with HTTPS 
and curl update 7.41.0.

【讨论】:

  • 谢谢你指点我!!它解决了我的问题。但是,CentOS7 在官方 repo 中没有 curl,因此需要构建或获取 rpm。 serverfault.com/a/738900/265703这篇文章可能会有所帮助。
  • 感谢您无限期地从我的生活中节省了时间;从源代码安装 curl 7.56 有帮助
猜你喜欢
  • 2017-03-16
  • 1970-01-01
  • 1970-01-01
  • 2018-06-07
  • 2020-06-03
  • 1970-01-01
  • 2020-04-28
  • 2019-01-28
  • 2016-07-04
相关资源
最近更新 更多