IAM policy example: ECR policy for cross-account pull, with a least privilege rewrite
Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.
A repository policy that lets account 444455556666 pull images from the repository web-app. The original also grants push actions. The rewrite keeps the three pull actions only, which matches the AWS documentation example for cross-account pulls. Resource names and account 111122223333 are placeholders used in AWS documentation.
Open the workbench ยท All examples
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CrossAccount",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::444455556666:root"
},
"Action": [
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload"
]
}
]
}
What it allows
- Allows principals in account 444455556666, when their own policies also allow it, to pull and push images in the repository.
What it allows
Allow 7 actions (ecr:BatchCheckLayerAvailability, ecr:GetDownloadUrlForLayer, ecr:BatchGetImage, ecr:PutImage, ecr:InitiateLayerUpload, ecr:UploadLayerPart, ecr:CompleteLayerUpload) on no resource named for AWS arn:aws:iam::444455556666:root.
Action or pattern Actions Access levels ecr:BatchCheckLayerAvailability1 Read 1 ecr:GetDownloadUrlForLayer1 Read 1 ecr:BatchGetImage1 Read 1 ecr:PutImage1 Write 1 ecr:InitiateLayerUpload1 Write 1 ecr:UploadLayerPart1 Write 1 ecr:CompleteLayerUpload1 Write 1
Checks
No flags from the six checks.
Push actions let the other account replace an image that other consumers deploy.
Least privilege rewrite
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CrossAccountPull",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::444455556666:root"
},
"Action": [
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage"
]
}
]
}
The rewrite removes the four push actions. The other account can pull but cannot replace images.
What it allows
Allow 3 actions (ecr:BatchCheckLayerAvailability, ecr:GetDownloadUrlForLayer, ecr:BatchGetImage) on no resource named for AWS arn:aws:iam::444455556666:root.
Action or pattern Actions Access levels ecr:BatchCheckLayerAvailability1 Read 1 ecr:GetDownloadUrlForLayer1 Read 1 ecr:BatchGetImage1 Read 1
Checks
No flags from the six checks.
Related pages
Sources
- Amazon ECR User Guide: repository policy examples, read 16 Nov 2026
- Amazon ECR User Guide: identity-based policy examples, read 16 Nov 2026
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026
Last reviewed 16 Nov 2026.