Not able to access private ECR repo and image

0

Hello, I am storing a docker image in the private repo of ECR, and while creating task definition, it gives me an error of

Private repository credentials are not a supported authentication method for ECR repositories.

I also tried with the secret manager, but it is not working. Can someone guide me on what the proper way is? Thanks for your time.

4 Antworten
0

Check this link it might help your case: https://docs.aws.amazon.com/AmazonECR/latest/userguide/Repositories.html#repository-concepts

profile picture
beantwortet vor 2 Jahren
0

Hello,

It sounds like your task execution role might not have the right permissions? Confirm that your ecsTaskExecutionRole has the following policy attached: AmazonECSTaskExecutionRolePolicy. The trust relationship should also look like:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Principal": {
                "Service": "ecs-tasks.amazonaws.com"
            },
            "Action": "sts:AssumeRole"
        }
    ]
}

If that doesn't work, I would verify that if you are doing any cross-account image pulling that your ECR repository has permissions that specifically allow the arn of your ecsTaskExecutionRole like so:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AllowCrossAccountPull",
      "Effect": "Allow",
      "Principal": {
        "AWS": [
          "arn:aws:iam::XXXXXXXXXXXX:role/ecsTaskExecutionRole"
        ]
      },
      "Action": [
        "ecr:BatchCheckLayerAvailability",
        "ecr:BatchGetImage",
        "ecr:GetDownloadUrlForLayer"
      ]
    }
  ]
}

Hope this helps! If not, please provide more detail on your architecture and IAM details.

beantwortet vor 2 Jahren
0

Hi, @grahamschuckman thanks for your reply. My AmazonECSTaskExecutionRolePolicy looks like this:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ecr:GetAuthorizationToken",
                "ecr:BatchCheckLayerAvailability",
                "ecr:GetDownloadUrlForLayer",
                "ecr:BatchGetImage",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ],
            "Resource": "*"
        }
    ]
}

and I am not doing any cross account image pulling. The image is stored is same AWS account in ECR private repo.

beantwortet vor 2 Jahren
0

Have a look at this article.

https://aws.amazon.com/premiumsupport/knowledge-center/ecs-tasks-pull-images-ecr-repository/

Follow the steps related to the ECS launch type you use (EC2 or Fargate). It should fix your issue.

AWS
Michael
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen