我在我的账户中有一个AWS IAM用户(我们称之为originAccount),它有权访问另一个账户(targetAccount),并且我试图克隆targetAccount中存在的CodeCommit存储库在我的Windows机器上使用我的originAccount凭据。AWS CodeCommit跨账户存储库访问不起作用
我可以登录并将角色切换到targetAccount就好,这就是我首先创建存储库的方式。除计费外,我可以完全访问targetAccount。我的IAM用户上启用了MFA。我试过暂时关闭它,但它没有帮助。但是,在MFA关闭的情况下,我可以成功执行aws s3 ls
,但不会为targetAccount发生错误。
SSH和HTTPS都不起作用。我可以作为测试克隆它与静态凭据,但这是不可接受的长期。我在这个东西是多么困难的AWS惊讶...
我在originAccount用户有这样的政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sts:AssumeRole"
],
"Resource": [
"arn:aws:iam::000000000000:role/Administrator"
]
}
]
}
管理员角色可以访问到的一切。 targetAccount有这种信任关系:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111111111111:user/MyUser"
},
"Action": "sts:AssumeRole",
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "true"
}
}
}
]
}
我试着去掉MFA位;没有帮助。我甚至在我的用户帐户上禁用了MFA,这也没有帮助。
我.aws\credentials
文件包含这些行:
[default]
aws_access_key_id = [originAccountKey]
aws_secret_access_key = [originAccountSecret]
[targetAccount]
aws_access_key_id = [originAccountKey]
aws_secret_access_key = [originAccountSecret]
我使用环境变量设置配置文件中使用如:
set AWS_DEFAULT_PROFILE=targetAccount
我.gitconfig
包含:
[credential "https://git-codecommit.us-east-1.amazonaws.com"]
helper = !'C:\\path\\to\\git-credential-AWSSV4.exe' --profile='targetAccount'
UseHttpPath = true
最初那是使用默认配置文件,但是也没有工作。
问题:
- 这可能吗?我究竟做错了什么?
- SSH和HTTPS都可以用于跨账户访问吗?这些文档令人困惑,但似乎表明只有拥有凭证助手的HTTPS才能工作(据称)。
- 这将与多因素身份验证一起工作吗?如果没有,那么CodeCommit只能关闭吗?
遗憾的是没有其他问题,我发现有这样的工作对我的答案...
我卸载并重新安装的Git的Windows只是可以肯定的是没有安装的凭据管理器(我不能不记得),但它仍然不起作用,说repository '...' not found
。尽管我可以通过HTTPS在originAccount中克隆存储库。
我得到这个在Linux上工作,然后尝试Windows ... – Josh
它的工作,谢谢!只是为了澄清,'role_arn'帐户ID是目标帐户(管理员存在)和'mfa_serial'帐户ID是原始帐户。我甚至不知道存在'mfa_serial'。最后,在我的'credentials'文件中,'[]'头文件中没有'profile'前缀,即我只有'[target_account]'。 – Josh