Closed ErmanB closed 3 years ago
I found the reason, and I'm writing here too in case anyone else faces same issue. I had to give permission to CodeBuild Service in Amazon ECR repository rather than adding policy to my build role. It successfully override custom image in CodeBuild agent after this.
{
"Version":"2012-10-17",
"Statement":[
{
"Sid":"CodeBuildAccessPrincipal",
"Effect":"Allow",
"Principal":{
"Service":"codebuild.amazonaws.com"
},
"Action":[
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability"
]
},
{
"Sid":"CodeBuildAccessCrossAccount",
"Effect":"Allow",
"Principal":{
"AWS":"arn:aws:iam::<AWS-account-ID>:root"
},
"Action":[
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability"
]
}
]
}
Reference: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-ecr.html
Hi,
I am trying to override CodeBuild image, however getting the following BUILD_CONTAINER_UNABLE_TO_PULL_IMAGE error. Do I do something wrong in "overrideImage" field in Jenkinsfile?
BUILD_CONTAINER_UNABLE_TO_PULL_IMAGE: Unable to pull customer's container image. CannotPullContainerError: Error response from daemon: pull access denied for ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/myrepo/codebuild-ansible, repository does not exist or may require 'docker login': denied: User: arn:aws:sts::131992011433
Added the following policy in my build role