Q92 — AWS DOP-C02 Ch.3

Question 92 of 100 | ← Chapter 3

A development team uses AWS CodeCommit for version control of an application. They use AWS CodePipeline, AWS CodeBuild, and AWS CodeDeploy for their CI/CD infrastructure. Recently, the team merged untested code into the main branch via a pull request requiring long-running tests. This caused downtime and required manual rollback. A DevOps engineer wants to automatically test pull requests in CodeCommit so reviewers can easily see test results as part of the pull request review process. What should the DevOps engineer do to meet this requirement?

Correct Answer: D. Create an Amazon EventBridge rule that responds to pullRequestStatusChanged events. Create an AWS Lambda function that invokes a CodePipeline pipeline with a CodeBuild action to run application tests. Program the Lambda function to post CodeBuild test results as a comment on the pull request after test completion.

Explanation

Option D is correct because the pullRequestStatusChanged event accurately captures state transitions of a pull request (e.g., from 'open' to 'testing'), enabling timely initiation of tests. The AWS Lambda function invokes CodeBuild via CodePipeline to execute application tests reliably. Posting test results as comments directly on the pull request ensures reviewers see outcomes inline during review—fulfilling the requirement. Options A and C use badges, which lack detailed pass/fail context; option B triggers only on creation, missing updates from subsequent commits. Thus, D best satisfies the need for timely, visible, and actionable test feedback.