AWS ECR CF 模板因“提供的存储库策略无效”而失败

Nei*_*son 6 amazon-web-services aws-cloudformation

此 CF 模板失败:

  MyECSrepo:
    Type: "AWS::ECR::Repository"
    Properties:
      RepositoryName: !Ref RepoName
      RepositoryPolicyText:
        Version: "2012-10-17"
        Statement:
          - Sid: AllowAll
            Effect: Allow
            Principal: 
              AWS:
                - arn:aws:iam::00000000000:group/admin
            Action:
          - "ecr:*"
Run Code Online (Sandbox Code Playgroud)

堆栈创建产生此错误:

“PolicyText”中的无效参数未能满足约束:“提供的存储库策略无效”

可能是什么问题?

Duk*_*ets 9

阅读了有关ECR Repository Policy的文档后,发现它仅限于 Principal 列表的用户和 root 帐户。因此,您可能需要换出以列出您想要授予访问权限的所有用户。

亚马逊文档有一些示例,其中有一些示例说明您可以使用它做什么。

  • 学习:如果用户存在,您也可以原则上只引用用户。用于测试的通用一次也将失败! (2认同)

and*_*ate 5

为了防止布偶公爵链接中断,这里有一个例子。今天我在使用自动创建的 json 时遇到了麻烦。这似乎解决了它。

    {
      "Version": "2008-10-17",
      "Statement": [
        {
          "Sid": "AllowPushPull",
          "Effect": "Allow",
          "Principal": {
            "AWS": "arn:aws:iam::<<id number of root user here>>:user/<<some iam user>>"
          },
          "Action": [
            "ecr:BatchCheckLayerAvailability",
            "ecr:BatchGetImage",
            "ecr:CompleteLayerUpload",
            "ecr:GetDownloadUrlForLayer",
            "ecr:InitiateLayerUpload",
            "ecr:PutImage",
            "ecr:UploadLayerPart"
          ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)