Q77 — AWS DOP-C02 Ch.3
Question 77 of 100 | ← Chapter 3
A development team uses AWS CodeCommit for application version control. They use AWS CodePipeline, AWS CodeBuild, and AWS CodeDeploy for their CI/CD infrastructure. Recently, the team merged a pull request in CodeCommit that introduced long-running tests into the main codebase, causing delays and resource exhaustion. A DevOps engineer wants to automatically test pull requests in CodeCommit so reviewers can easily see the results as part of the pull request review process.
- A. Create an Amazon EventBridge rule to respond to pullRequestStatusChanged events. Create an AWS Lambda function that invokes a CodePipeline pipeline containing a CodeBuild action to run application tests. Program the Lambda function to post a CodeBuild badge as a comment on the pull request so developers can see it during code review.
- B. Create an Amazon EventBridge rule to respond to pullRequestCreated events. Create an AWS Lambda function that invokes a CodePipeline pipeline containing a CodeBuild action to run application tests. Program the Lambda function to post the CodeBuild test results as a comment on the pull request when testing completes.
- C. Create an Amazon EventBridge rule that responds to both pullRequestCreated and pullRequestSourceBranchUpdated events. Create an AWS Lambda function that invokes a CodePipeline pipeline containing a CodeBuild action to run application tests. Program the Lambda function to post a CodeBuild badge as a comment on the pull request so developers can see it during code review. ✓
- D. Create an Amazon EventBridge rule to respond to pullRequestStatusChanged events. Create an AWS Lambda function that invokes a CodePipeline pipeline containing a CodeBuild action to run application tests. Program the Lambda function to post the CodeBuild test results as a comment on the pull request when testing completes.
Correct Answer: C. Create an Amazon EventBridge rule that responds to both pullRequestCreated and pullRequestSourceBranchUpdated events. Create an AWS Lambda function that invokes a CodePipeline pipeline containing a CodeBuild action to run application tests. Program the Lambda function to post a CodeBuild badge as a comment on the pull request so developers can see it during code review.
Explanation
Amazon EventBridge rules must respond to both pullRequestCreated (triggered when a PR is first opened) and pullRequestSourceBranchUpdated (triggered when new commits are pushed to the PR’s source branch) to ensure tests re-run on every code change. AWS documentation confirms these are the two relevant CodeCommit events for full PR lifecycle coverage. Options A, B, and D each listen to only one event type and thus fail to trigger retesting after subsequent commits. Option C correctly configures dual-event triggering, invokes CodeBuild via CodePipeline, and posts a visual CodeBuild badge—providing immediate, intuitive pass/fail feedback directly in the PR interface, satisfying the requirement for reviewer visibility.