Skip to content
IAM Policy Generator

IAM policy example: ECR policy for cross-account pull, with a least privilege rewrite

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

  1. 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 patternActionsAccess levels
    ecr:BatchCheckLayerAvailability1Read 1
    ecr:GetDownloadUrlForLayer1Read 1
    ecr:BatchGetImage1Read 1
    ecr:PutImage1Write 1
    ecr:InitiateLayerUpload1Write 1
    ecr:UploadLayerPart1Write 1
    ecr:CompleteLayerUpload1Write 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

  1. Allow 3 actions (ecr:BatchCheckLayerAvailability, ecr:GetDownloadUrlForLayer, ecr:BatchGetImage) on no resource named for AWS arn:aws:iam::444455556666:root.

    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: repository policy examples, read 16 Nov 2026
  2. Amazon ECR User Guide: identity-based 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.