Amazon ECR 的私有注册表策略示例
以下示例显示了您可用于控制用户对 Amazon ECR 注册表所具备权限的注册表权限策略声明。
注意
在每个示例中,如果从您的注册表权限声明中删除 ecr:CreateRepository
操作,复制仍然可能发生。但是,要成功复制,您需要在账户中创建具有相同名称的存储库。
示例:允许源账户的根用户复制所有存储库
以下注册表权限策略允许源账户的根用户复制所有存储库。
{ "Version":"2012-10-17", "Statement":[ { "Sid":"ReplicationAccessCrossAccount", "Effect":"Allow", "Principal":{ "AWS":"arn:aws:iam::
source_account_id
:root
" }, "Action":[ "ecr:CreateRepository", "ecr:ReplicateImage" ], "Resource": [ "arn:aws:ecr:us-west-2:your_account_id
:repository/*
" ] } ] }
示例:允许来自多个账户的根用户
以下注册表权限策略包含两个语句。每个语句都允许源账户的根用户复制所有存储库。
{ "Version":"2012-10-17", "Statement":[ { "Sid":"ReplicationAccessCrossAccount1", "Effect":"Allow", "Principal":{ "AWS":"arn:aws:iam::
source_account_1_id
:root
" }, "Action":[ "ecr:CreateRepository", "ecr:ReplicateImage" ], "Resource": [ "arn:aws:ecr:us-west-2:your_account_id
:repository/*
" ] }, { "Sid":"ReplicationAccessCrossAccount2", "Effect":"Allow", "Principal":{ "AWS":"arn:aws:iam::source_account_2_id
:root
" }, "Action":[ "ecr:CreateRepository", "ecr:ReplicateImage" ], "Resource": [ "arn:aws:ecr:us-west-2:your_account_id
:repository/*
" ] } ] }
示例:允许源账户的根用户复制带有前缀 prod-
的所有存储库。
以下注册表权限策略允许源账户的根用户复制以 prod-
开头的所有存储库。
{ "Version":"2012-10-17", "Statement":[ { "Sid":"ReplicationAccessCrossAccount", "Effect":"Allow", "Principal":{ "AWS":"arn:aws:iam::
source_account_id
:root
" }, "Action":[ "ecr:CreateRepository", "ecr:ReplicateImage" ], "Resource": [ "arn:aws:ecr:us-west-2:your_account_id
:repository/prod-*
" ] } ] }