Skip to content
IAM Policy Generator

IAM policy example: pull images from one ECR repository, with a least privilege rewrite

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

  1. Allow 65 actions (ecr:*) on every resource.

    Action or patternActionsAccess levels
    ecr:*65List 5, Read 22, Write 32, Permissions management 4, Tagging 2

Checks

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

  1. Allow 1 action (ecr:GetAuthorizationToken) on every resource.

    Action or patternActionsAccess levels
    ecr:GetAuthorizationToken1Read 1
  2. Allow 3 actions (ecr:BatchCheckLayerAvailability, ecr:GetDownloadUrlForLayer, ecr:BatchGetImage) on arn:aws:ecr:us-east-1:111122223333:repository/web-app.

    Action or patternActionsAccess levels
    ecr:BatchCheckLayerAvailability1Read 1
    ecr:GetDownloadUrlForLayer1Read 1
    ecr:BatchGetImage1Read 1

Checks

No flags from the six checks.

Sources

  1. Amazon ECR User Guide: identity-based policy examples, read 16 Nov 2026
  2. Amazon ECR User Guide: repository policy examples, read 16 Nov 2026
  3. AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026

Last reviewed 16 Nov 2026.