AWS ECR allow roles from secondary account

0

I have an ECR in a prod account that I want to grant push access to from the dev role.

This is my current policy

{
  "Version": "2008-10-17",
  "Statement": [
    {
      "Sid": "AllowPushPull",
      "Effect": "Allow",
      "Principal": {
        "AWS": [
          "arn:aws:iam::account:role/rolename",
          "arn:aws:sts::account:assumed-role/rolename/instance",
          "arn:aws:sts::account:assumed-role/rolename/AWSCLI-Session"
        ]
      },
      "Action": [
        "ecr:BatchCheckLayerAvailability",
        "ecr:BatchGetImage",
        "ecr:CompleteLayerUpload",
        "ecr:DescribeImages",
        "ecr:DescribeRepositories",
        "ecr:GetDownloadUrlForLayer",
        "ecr:GetLifecyclePolicy",
        "ecr:GetLifecyclePolicyPreview",
        "ecr:GetRepositoryPolicy",
        "ecr:InitiateLayerUpload",
        "ecr:ListImages",
        "ecr:PutImage",
        "ecr:PutLifecyclePolicy",
        "ecr:SetRepositoryPolicy",
        "ecr:StartLifecyclePolicyPreview",
        "ecr:UploadLayerPart"
      ]
    }
  ]
}

Running aws sts get-caller-identity I can see I have the role checked out "arn:aws:sts::account:assumed-role/rolename/AWSCLI-Session" but I do not have access to push.

I receive the following until timeout.

The push refers to repository [account.dkr.ecr.us-west-2.amazonaws.com/repo] 87e2ce75493a: Retrying in 4 seconds

My non-prod account does exist in us-east-1. but my login command specifies west.

task: [docker:ecr-login] aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin accpunt.dkr.ecr.us-west-2.amazonaws.com

Any ideas what may be my problem on this repo?

(this works with my production account so the registry is valid)

Also this works when I use my dev account and allow the user IAM

1개 답변
1

Have a look at this article. It provides the required steps to allow a secondary account to push or pull images from an ECR image repository.

https://aws.amazon.com/premiumsupport/knowledge-center/secondary-account-access-ecr/

Follow these steps carefully and make sure you that your secondary account has Amazon ECR permissions listed in "AmazonEC2ContainerRegistryPowerUser" managed policy. These permissions are required to pull or push from your primary account.

AWS
Michael
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠