简体   繁体   English

我在 AWS 中添加了哪些权限以启用 ecr:getAuthorizationToken?

[英]What permissions do I add in AWS to enable ecr:getAuthorizationToken?

I'm trying to follow the steps to use amazon elastic container registry (ECR) but I'm stuck at the first step, which is obtaining an auth token.我正在尝试按照使用亚马逊弹性容器注册表(ECR)的步骤,但我被困在第一步,即获取身份验证令牌。

Command:命令:

aws ecr get-login

Or...或者...

aws ecr get-login --region=us-west-2

Error:错误:

An error occurred (AccessDeniedException) when calling the GetAuthorizationToken operation: User: arn:aws:iam::9#####4:user/### is not authorized to perform: ecr:GetAuthorizationToken on resource: *

AWS Permissions on user for region us-west-2:区域 us-west-2 的用户 AWS 权限:

AmazonEC2FullAccess
AmazonEC2ContainerRegistryFullAccess
Billing
AdministratorAccess
AmazonECS_FullAccess 

AWS CLI version: AWS CLI 版本:

aws help --version
aws-cli/1.14.40 Python/3.6.4 Darwin/18.2.0 botocore/1.8.44

Please note that you're not allowing your user any access to ECR in a sense. 请注意,您在某种意义上不允许用户访问ECR。 Try adding the following policy to the user: 尝试向用户添加以下策略:

{
"Version": "2012-10-17",
"Statement": [{
    "Effect": "Allow",
    "Action": [
        "ecr:GetAuthorizationToken",
        "ecr:BatchCheckLayerAvailability",
        "ecr:GetDownloadUrlForLayer",
        "ecr:GetRepositoryPolicy",
        "ecr:DescribeRepositories",
        "ecr:ListImages",
        "ecr:DescribeImages",
        "ecr:BatchGetImage"
    ],
    "Resource": "*"
}]
}

https://docs.aws.amazon.com/AmazonECR/latest/userguide/ecr_managed_policies.html#AmazonEC2ContainerRegistryReadOnly https://docs.aws.amazon.com/AmazonECR/latest/userguide/ecr_managed_policies.html#AmazonEC2ContainerRegistryReadOnly

As general advice, ecr:GetAuthorizationToken must apparently be applied to all resources * but all other ECR permissions can be scoped.作为一般建议, ecr:GetAuthorizationToken显然必须应用于所有资源*但所有其他 ECR 权限都可以限定范围。 When setting up ECR permissions as below, that user/role can login into Docker via CLI and still only access those images that user/role is supposed to.如下设置 ECR 权限时,该用户/角色可以通过 CLI 登录到 Docker 并且仍然只能访问该用户/角色应该访问的那些图像。

Example with scoped permissions:具有范围权限的示例:

{
  "Version": "2012-10-17",
  "Statement": [
    {           
      "Effect": "Allow",
      "Action": [
        "ecr:BatchGetImage",
        "ecr:BatchCheckLayerAvailability",
        "ecr:CompleteLayerUpload",
        "ecr:GetDownloadUrlForLayer",
        "ecr:InitiateLayerUpload",
        "ecr:PutImage",
        "ecr:UploadLayerPart"
      ],
      "Resource": "arn:aws:ecr:${region}:${account}:repository/${repo-name}"
    },
    {
      "Effect": "Allow",
      "Action": "ecr:GetAuthorizationToken",
      "Resource": "*"
    }
  ]
}

From my observations, scoping ecr:GetAuthorizationToken to any ECR repositories will result in AccessDeniedException .根据我的观察,将ecr:GetAuthorizationToken范围限定到任何 ECR 存储库都会导致AccessDeniedException

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS ECR 获取授权令牌 - AWS ECR GetAuthorizationToken AWS ECR GetAuthorizationToken 问题 - AWS ECR GetAuthorizationToken Issue AWS ECR 用户无权执行:ecr-public:GetAuthorizationToken 对资源:* - AWS ECR user is not authorized to perform: ecr-public:GetAuthorizationToken on resource: * 如何让 Docker Swarm 管理器使用 IAM 角色权限从 AWS ECR 中提取图像? - How do I get a Docker Swarm manager to pull images from AWS ECR using IAM Role permissions? 如何在 AWS Keyspaces 中添加权限? - How do I add permissions in AWS Keyspaces? kubernetes:默认AWS ECR权限 - kubernetes: default AWS ECR permissions AWS CodeBuild GetAuthorizationToken 失败 - AWS CodeBuild GetAuthorizationToken failed AWS CDK - 如何有条件地创建 ECR 存储库 - AWS CDK - How do I create ECR repo conditionally 如何在AWS SQS队列上添加权限? - How do I add permissions on an AWS SQS Queue? 未授权执行:ecr:GetAuthorizationToken on resource: * 因为没有基于身份的策略允许 ecr:GetAuthorizationToken - Not authorized to perform: ecr:GetAuthorizationToken on resource: * because no identity-based policy allows the ecr:GetAuthorizationToken
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM