A developer creates a new AWS CodeBuild project and configures a custom IAM role for the build environment. However, when attempting to run the build, the execution fails immediately before starting any phases with an error indicating that CodeBuild is unable to assume the configured service role. Which of the following is the most likely cause of this failure?
- AThe buildspec.yml file has been placed in a subdirectory of the source code repository instead of the root directory.
- BThe permissions policy attached to the custom IAM role is missing the sts:AssumeRole permission for the CodeBuild service.
- The trust policy of the custom IAM role does not grant the codebuild.amazonaws.com service principal permission to assume the role.Cevap
- DThe credentials required for the build environment were stored as Systems Manager Parameter Store String parameters instead of SecureString parameters.
Cevap
The trust policy of the custom IAM role does not grant the codebuild.amazonaws.com service principal permission to assume the role.
For AWS CodeBuild to execute a build project, it must assume the specified IAM service role. This requires the IAM role's trust policy (trust relationship) to explicitly list the CodeBuild service principal (codebuild.amazonaws.com) in the Principal block and allow the sts:AssumeRole action. If the trust policy is missing or misconfigured, CodeBuild will fail to assume the role and the build cannot start.
Adım Adım Çözüm
Anahtar Kavram
AWS CodeBuild IAM service role trust relationship