A developer is configuring an AWS CodePipeline where an AWS CodeBuild stage runs automated unit tests. The CodeBuild project has been assigned a custom IAM service role with permission policies that grant access to target Amazon S3 buckets and Amazon CloudWatch Logs. However, when the pipeline runs, the CodeBuild execution fails during the start phase with the error message: `CodeBuild is not authorized to perform: sts:AssumeRole on the specified service role`. What is the correct action to troubleshoot and resolve this failure?
- Update the trust policy of the custom IAM service role to allow the codebuild.amazonaws.com service principal to perform the sts:AssumeRole action.Cevap
- BAdd the sts:AssumeRole action to the identity-based permission policy attached to the custom IAM service role.
- CCreate a buildspec.yml file in the root of the source code repository and specify the sts:AssumeRole command under the pre_build phase.
- DModify the AWS CodePipeline service role permissions to allow the pipeline to assume the container's Amazon ECS task execution role.
Cevap
Update the trust policy of the custom IAM service role to allow the codebuild.amazonaws.com service principal to perform the sts:AssumeRole action.
The correct action is to update the trust policy of the custom IAM service role to allow the codebuild.amazonaws.com service principal to perform the sts:AssumeRole action. For AWS CodeBuild to execute a build, the CodeBuild service itself must be authorized to assume the role assigned to the project. This authorization is granted through the role's trust policy, not its permission policy.
Adım Adım Çözüm
Anahtar Kavram
AWS CodeBuild Service Role Trust Relationships