The reason is CodeBuild service role needs permission to access the CodePipeline S3 bucket.
To fix it, you can attach an inline policy or modify existing policy to allow these actions to access the objects in your CodePipeline S3 bucket (to specify Resources for the policy)
s3:GetObject
s3:GetObjectVersion
s3:PutObject
This is the policy in json, remember to replace S3-BUCKET-NAME with your actual codepipeline s3 bucket name.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:GetObjectVersion"
],
"Resource": "arn:aws:s3:::S3-BUCKET-NAME/*"
}
]
}
To look for the S3 bucket name, you can do the following on AWS console to trace the source of error:
- Go to CodeBuild
- Select Build projects on left panel
- Choose your project, Build history will be displayed
- click the Build run item that has failed status
- See the error in Build logs if there is
- Choose Phase details
- CodeBuild most probably failed at DOWNLOAD_SOURCE phase with the following error message:
CLIENT_ERROR: AccessDenied: Access Denied status code: 403, request id:
requestId, host id: hostId for primary source and source version
arn:aws:s3:::S3-BUCKET-NAME/path