IAM policy example: pull images from one ECR repository, with a least privilege rewrite
Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.
Allows a role to log in to the registry and pull images from one repository, web-app. The login token action has no resource-level support, so it uses a wildcard. The original allows ecr:* on every repository. The names and the account ID 111122223333 are AWS documentation placeholders.
Open the workbench ยท All examples
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Ecr",
"Effect": "Allow",
"Action": "ecr:*",
"Resource": "*"
}
]
}
What it allows
- Allows every ECR action on all repositories, including pushing and deleting images.
What it allows
Allow 65 actions (ecr:*) on every resource.
Action or pattern Actions Access levels ecr:*65 List 5, Read 22, Write 32, Permissions management 4, Tagging 2
Checks
- High Allows 36 write or permissions-management actions (4 permissions management) on every resource ("Resource": "*"). AWS documentation for this check
The action ecr:* covers 65 actions, including deleting repositories and replacing images.
Least privilege rewrite
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Login",
"Effect": "Allow",
"Action": "ecr:GetAuthorizationToken",
"Resource": "*"
},
{
"Sid": "PullOneRepo",
"Effect": "Allow",
"Action": [
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage"
],
"Resource": "arn:aws:ecr:us-east-1:111122223333:repository/web-app"
}
]
}
The rewrite splits the login token from the three pull actions and names one repository. Pushing and deleting are removed.
What it allows
Allow 1 action (ecr:GetAuthorizationToken) on every resource.
Action or pattern Actions Access levels ecr:GetAuthorizationToken1 Read 1 Allow 3 actions (ecr:BatchCheckLayerAvailability, ecr:GetDownloadUrlForLayer, ecr:BatchGetImage) on arn:aws:ecr:us-east-1:111122223333:repository/web-app.
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: identity-based policy examples, read 16 Nov 2026
- Amazon ECR User Guide: repository 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.