Kushal Chordiya
Kushal Chordiya

Reputation: 151

Github actions fails when pushing docker image to ECR

I'm referring to the official github guide to set up automated deploy to ECS https://docs.github.com/en/actions/deployment/deploying-to-your-cloud-provider/deploying-to-amazon-elastic-container-service

My deploy.yaml workflow looks identical to the one in the above link, only with the correct environment variables substituted

i've completed all the steps as required and have all the necessary infrastructure on AWS up and running. But when the workflow get's triggered, it always fails at pushing the docker image to ECR. After retrying for a couple of times, it exits with

EOF
Error: Process completed with exit code 1.

From the output i can see on the github actions, I believe the login to ecr step succeeded and also can confirm that it's pushing to the right ECR repository, but for some reason the push fails.

I've already pushed images to the repository locally and it works, so I don't think anything is wrong on the AWS side of things.

Upvotes: 6

Views: 10029

Answers (5)

Dhiraj Dighe
Dhiraj Dighe

Reputation: 1

I also faced the same problem, but what I found that, the ECR repo where I was trying to push doesn't exist. I deleted the repo for some testing purpose and forgot to re-create and trying docker push and it was failing like below :

f9cb3f1f1d3d: Retrying in 1 second

EOF

Error: Process completed with exit code 1.

I re-created the ECR repo and able to do docker push successfully.

Upvotes: 0

Had the same issue. Saw here that you can lookup the logs for this issue in Cloudtrail. After doing so I saw that my user was missing the ecr:InitiateLayerUpload action. After updating my user I was able to push to ECR

Upvotes: 4

Abhishek
Abhishek

Reputation: 106

While logging into AWS account using the aws-actions/configure-aws-credentials@v1, I was specifying wrong aws-region.

AWS region should be same as the ecr repo region. Else, even if login is successful, push will fail.

Upvotes: 8

Matt C
Matt C

Reputation: 11

I had this problem when my IAM user did not have sufficient permissions to write to the repository. My updated permissions were as follows, which worked.

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "ecr:CompleteLayerUpload",
                "ecr:GetAuthorizationToken",
                "ecr:UploadLayerPart",
                "ecr:InitiateLayerUpload",
                "ecr:BatchCheckLayerAvailability",
                "ecr:PutImage"
            ],
            "Resource": "*"
        }
    ]
}

Upvotes: 1

Kushal Chordiya
Kushal Chordiya

Reputation: 151

I realized my own mistake with this. In the environment file where i'm supposed to specify the repository-name i had instead specified the full repository ID meaning if the repository is named my-ecr-repo, i had instead accidentally written .dkr.ecr.us-east-1.amazonaws.com/my-ecr-repo setting the name to just my-ecr-repo solved the problem

Upvotes: 9

Related Questions