CodeBuild Phases Failure

0

I setup a CI/CD pipeline (CodeCommit -> CodeBuild -> CodeDeploy) controlled by CodePipeline Enter image description here

Whether using environment variables or hardcoded values, I receive the same error. I made sure my service role has the below permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ecr:GetDownloadUrlForLayer",
        "ecr:BatchGetImage",
        "ecr:CompleteLayerUpload",
        "ecr:UploadLayerPart",
        "ecr:InitiateLayerUpload",
        "ecr:BatchCheckLayerAvailability",
        "ecr:PutImage"
      ],
      "Resource": "arn:aws:ecr:eu-west-1:<ACCOUNT_ID>:repository/<Respository_name>"
    }
  ]
}

profile picture
asked 10 months ago396 views
2 Answers
1
Accepted Answer

Hi, your role needs more permissions than the above. See https://docs.aws.amazon.com/codebuild/latest/userguide/setting-up.html#setting-up-service-role for the full list

profile pictureAWS
EXPERT
answered 10 months ago
  • I noticed that the result is the same as per my below comment:

  • The action ecr:GetAuthenticationToken needs to have '*' as its resource.

0

Hi, please send the log error from the pipeline itself?

profile picture
answered 10 months ago
  • [Container] 2023/06/22 21:07:31 Command did not exit successfully aws ecr get-login --region eu-west-1 | docker login --username AWS --password-stdin 883907968008.dkr.ecr.eu-west-1.amazonaws.com exit status 1 [Container] 2023/06/22 21:07:31 Phase complete: PRE_BUILD State: FAILED [Container] 2023/06/22 21:07:31 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: aws ecr get-login --region eu-west-1 | docker login --username AWS --password-stdin 883907968008.dkr.ecr.eu-west-1.amazonaws.com. Reason: exit status 1

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions