Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github actions:Build and Push docker image iam policy

Hello I am using Github actions AWS EC2 and IAM policy for building and pushing docker image. however i am getting the following error:

Error: buildx failed with: error: failed to solve: unexpected status: 403 Forbidden.

The iam policy I am using is as follows:

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

Not sure what i should do in order for this to work

like image 328
Divy Avatar asked Oct 14 '25 15:10

Divy


1 Answers

You have to include ecr:BatchGetImage for the image in question. The complete policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ecr:CompleteLayerUpload",
                "ecr:BatchGetImage",
                "ecr:UploadLayerPart",
                "ecr:InitiateLayerUpload",
                "ecr:BatchCheckLayerAvailability",
                "ecr:PutImage"
            ],
            "Resource": "arn:aws:ecr:region:111122223333:repository/repository-name"
        },
        {
            "Effect": "Allow",
            "Action": "ecr:GetAuthorizationToken",
            "Resource": "*"
        }
    ]
}
like image 185
weberc2 Avatar answered Oct 17 '25 05:10

weberc2



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!