2

How do ECR policies differ from IAM policies?

The language around the ECR policies seem to indicate it is similar to the S3 bucket policy.

Does it allow you to grant access not using IAM?

If I wanted to grant another account access to registry can I use an ECR policy or do I still need a cross account role?

jtoberon
  • 8,706
  • 1
  • 35
  • 48
user2115867
  • 191
  • 1
  • 9

2 Answers2

2

The language around the ECR policies seem to indicate it is similar to the S3 bucket policy.

Yep, they are. Both ECR repository policies and S3 bucket policies control permissions of specific resources rather than permissions of principals (identities). In the case of ECR, it lets you define permissions for a specific repository.

Does it allow you to grant access not using IAM?

Sort of. You need both an IAM policy and a repository policy to express some kinds of permissions. For example, an IAM policy on a user might have permissions like ecr:* in order to allow the user to make API calls to ECR and then a repository policy might grant control over a particular repository.

If I wanted to grant another account access to registry can I use an ECR policy or do I still need a cross account role?

This is one of the primary use-cases of repository policies. A user in account A might have permission to make ECR API calls with ecr:* in the IAM policy. A repository in account B could then grant cross-account access to account A, at which point the account A user does not need to assume a cross-account role in order to access the repository.

Samuel Karp
  • 4,373
  • 22
  • 34
1

According the documentation, you can allow cross-account access to your ECR with just the repo policy:

For Principal, choose the scope of users to apply the policy statement to.

  • You can apply the statement to all authenticated AWS users by selecting the Everybody check box.

  • You can apply the statement to all users under specific AWS accounts by listing those account numbers (for example, 111122223333) in the AWS account number(s) field.

  • You can apply the statement to roles or users under your AWS account by checking the roles or users under the All IAM entities list and choosing >> Add to move them to the Selected IAM entities list.

So you don't need to setup cross-account role assumption, but I imagine you would have to grant the appropriate permissions to the users/groups/roles in the remote account to allow them to talk out to your ECR.

Community
  • 1
  • 1
Himal
  • 3,002
  • 1
  • 18
  • 17