A dev team uses CodeCommit, CodePipeline, and CodeBuild. Pull requests are used for changes, but failing tests in the main pipeline block progress. The team wants unit and integration tests to run on each pull request before merge. What solution meets this need?
Choose an answer
Tap an option to check your answer.
Correct answer: Create an Amazon EventBridge rule to match pullRequestCreated events from CodeCommit Create a CodeBuild project to run the unit and integration tests. Configure the CodeBuild project as a target of the EventBridge rule that includes a custom event payload with the CodeCommit repository and branch information from the event..
Why this is the answer
The correct solution leverages EventBridge to trigger a dedicated CodeBuild project upon pull request creation. EventBridge can detect pullRequestCreated events from CodeCommit and then invoke a CodeBuild project as a target. This CodeBuild project will execute the unit and integration tests against the pull request's code. This approach ensures tests run before merging, preventing failing code from reaching the main branch. The first incorrect option, using CodeCommit approval rules, is designed for manual approvals or external approval services, not direct CodeBuild invocation based on test results. The third option, modifying the main CodePipeline, is less efficient as it would involve the entire pipeline for every pull request, potentially deploying non-production code or unnecessarily consuming resources. The fourth option, using CodeCommit notification rules, is for sending notifications (e.g., to SNS, Lambda) and cannot directly invoke a CodeBuild project to run tests and report status back to the pull request.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed