【发布时间】:2021-10-21 00:00:48
【问题描述】:
我正在尝试将 docker 映像从我的 mac 推送到 ECR。我将身份添加到 aws-vault,但使用 aws-vault 无法获取密码。我的同伴有同样的权限,他可以毫无问题地登录 ECR。
.aws % aws-vault list
Profile Credentials Sessions
======= =========== ========
identity identity -
.aws % ENCRYPTED_PASSWORD=$(aws-vault exec identity -- aws ecr get-login-password --region us-west-2)
An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:iam::97xxxxxxxxxx:user/xxxxx.xxxxxx@xxxxxxxxx.com is not authorized to perform: ecr:GetAuthorizationToken on resource: * with an explicit deny in an identity-based policy
我们使用的是同一个角色。我打算在获得 ENCRYPTED_PASSWORD 后执行以下行--
aws-vault exec identity -- aws ecr --region us-west-2 | docker login -u AWS -p ${ENCRYPTED_PASSWORD} xxxxxxxxxxxx.dkr.ecr.us-west-2.amazonaws.com/my-ecr
我的 .aws/config 有这行参考上面。
[profile identity]
由于我的队友拥有相同的策略/权限,我不认为“GetAuthorizationToken”是个问题。还有什么?我正在尝试找到一种方法将我的 docker 图像从 Mac 推送到 ECR。
完全重做配置,将所有角色与身份相关联。
[profile xx-xxxx-services-monitoring]
role_arn=arn:aws:iam::xxxxxxxxxxxx:role/XXMonitoring
source_profile=identity
sparent_profile=mfa
[profile identity]
现在是令牌问题——我从 MFA Authenticator 输入了代码但失败了
.aws % aws-vault exec xx-xxxx-main-admin -- aws ecr get-login --region us-west-2
Warning: parent_profile is deprecated, please use include_profile instead in your AWS config
Enter token for arn:aws:iam::xxxxxxxxxxxx:mfa/xxxxxx.xxxx@xxxxxx.com: **125492**
aws-vault: error: exec: Failed to get credentials for xx-xxxx-main-admin: AccessDenied: MultiFactorAuthentication failed, unable to validate MFA code. Please verify your MFA serial number is valid and associated with this user.
status code: 403, request id: 25808115-d9fa-480d-87d4-xxxxxxxxxxxxx
从 Authenticator MFA 来看,令牌似乎无效
【问题讨论】:
标签: amazon-web-services docker aws-cli amazon-ecr