Search code examples
amazon-web-servicesamazon-ecr

Share all ECR repositories with another AWS account


I have a lot of repositories in ECR, and there's another AWS account that needs access to all of these repositories.

I'm trying to set my AWS so that another AWS account would have access to all my ECR repositories but all the documentation just shows how to share a specific ECR repo (instead of sharing all the ECR repos).

Is it possible to share all the ECR repos at once? Thanks ahead!


Solution

  • When you share an ECR repository with someone in a different account you are using a resource-based policy to grant them access. This type of policy is specific to the resource and not to the entire service.

    If you don't want to apply a resource-based policy to every ECR repository, then you will need to create an IAM role that can be assumed by users in the other account (cross account role), and you need to give this role an identity-based policy that allows access to every ECR repository in your account.

    Users in the other account will need to assume this role in order to access the repositories. Do note that when a user assumes a role, they are granted the permissions defined by the role/policy and give up their original permissions.

    This documentation page explains the differences between resource-based and identity policies.