无法为 AWS ECR 创建策略
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPushPull",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<account_id>:user/root"
},
"Action": [
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:CompleteLayerUpload",
"ecr:GetDownloadUrlForLayer",
"ecr:InitiateLayerUpload",
"ecr:PutImage",
"ecr:UploadLayerPart"
],
"Resource": [
"xxx.dkr.ecr.us-west-2.amazonaws.com/yyy"
]
}
]
}
我尝试使用的命令是:
aws ecr set-repository-policy --repository-name yyy --policy-text file://ecr-policy.json
如果我在 Linux 计算机中执行 ls
,我可以在运行此命令的同一文件夹中看到此 ecr-policy.json
。
我想授予我自己访问权限。
我总是收到错误:
调用 SetRepositoryPolicy 操作时发生错误 (InvalidParameterException):“PolicyText”处的无效参数无法满足约束:“提供的存储库策略无效”
我检查了我的 AWS ARN,它以 root
结尾。
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowPushPull",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<account_id>:user/root"
},
"Action": [
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:CompleteLayerUpload",
"ecr:GetDownloadUrlForLayer",
"ecr:InitiateLayerUpload",
"ecr:PutImage",
"ecr:UploadLayerPart"
],
"Resource": [
"xxx.dkr.ecr.us-west-2.amazonaws.com/yyy"
]
}
]
}
Command I try to use is:
aws ecr set-repository-policy --repository-name yyy --policy-text file://ecr-policy.json
If I do ls
in my linux machine I can see this ecr-policy.json
in same folder where I run this command.
I want to grant access to myself.
I am always getting error:
An error occurred (InvalidParameterException) when calling the SetRepositoryPolicy operation: Invalid parameter at 'PolicyText' failed to satisfy constraint: 'Invalid repository policy provided'
I checked my AWS ARN and it ends with root
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想向自己授予访问权限。
您不需要资源部分,因为此语句将附加到特定存储库。尝试在 Console > 添加以下语句: ECR> 存储库 > [在
Images
表上选择一个存储库]> 权限:注意:替换<帐户#>使用您的 AWS 账户 ID。
i want to grant access to myself.
You don't need a resource section because this statement will be attached to a specific repository. Try add the following statement at Console > ECR > Repositories > [Select a repo on the
Images
table] > Permissions:NOTE: Replace <account #> with your AWS account ID.
删除策略 json 文件中的
Resource
或者您可以在 AWS 控制台上设置
Amazon ECR >存储库
权限
选项卡Remove
Resource
in Policy json fileOr you can set on AWS Console
Amazon ECR > Repositories
permissions
tab尝试以下格式的资源:
https://docs。 aws.amazon.com/AmazonECR/latest/userguide/security_iam_service-with-iam.html
try resource in a format:
https://docs.aws.amazon.com/AmazonECR/latest/userguide/security_iam_service-with-iam.html