DOP-C02 Configuration Management and IaC Practice Question
A company uses AWS CodeCommit and CodePipeline. The pipeline triggers on commits to the main branch. The DevOps engineer wants to add a stage that runs unit tests in a build environment. After the tests pass, the pipeline should deploy to a staging environment. If the tests fail, the pipeline should stop and notify the team. Which AWS service should be used to implement this workflow?
⚠ Common exam trap
Candidates often confuse CodeBuild with CodeDeploy, thinking that deployment services also handle testing, or they may assume CodeStar is a build service when it is actually a project management layer that does not execute code.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
AWS CodeBuild
AWS CodeBuild is the correct service because it can be integrated directly into a CodePipeline as a build action that runs unit tests in a managed build environment. When tests fail, CodeBuild can be configured to exit with a non-zero status, which causes CodePipeline to stop the execution and optionally trigger notifications via Amazon SNS or CloudWatch Events. This matches the requirement for a build stage that runs tests and conditionally proceeds or halts the pipeline.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
AWS CodeBuild
Why this is correct
AWS CodeBuild is the correct choice because it is a fully managed build and test service that integrates natively as a build action within CodePipeline. You can define unit tests in a buildspec file that execute during the build stage; if any test command returns a non-zero exit code, CodeBuild marks the action as failed, which immediately halts the pipeline and prevents the deployment stage from running. This makes CodeBuild the standard, purpose-built mechanism for implementing a test gate that can conditionally stop a pipeline. It also produces build artifacts and detailed logs, enabling seamless handoff to later deployment stages when tests pass.
- ✗
AWS CodeStar
Why it's wrong here
AWS CodeStar is not an execution service for CI/CD but rather a project management and development dashboard that aggregates issues, code, team collaboration, and a unified view of your software project. Although CodeStar can scaffold an entire pipeline for you by creating CodeCommit, CodeBuild, and CodeDeploy resources behind the scenes, it itself does not run builds or tests and cannot be inserted as a stage or action inside CodePipeline. The pipeline itself operates through the underlying CodePipeline service, not through CodeStar. Therefore, it cannot serve as the component that runs unit tests or fails the pipeline based on test results.
- ✗
AWS Lambda
Why it's wrong here
Lambda lacks native integration with CodePipeline’s stage-level failure and success branching logic; it cannot directly halt the pipeline or conditionally trigger a deployment based on test results without custom orchestration code. It is tempting because Lambda can execute arbitrary code for testing or notifications, and would be correct for a custom post-pipeline action, such as invoking a third-party notification service after a pipeline stage completes, but not for controlling pipeline flow itself.
- ✗
AWS CodeDeploy
Why it's wrong here
AWS CodeDeploy is a deployment automation service that handles rolling out application revisions to targets such as EC2 instances, Lambda functions, or Amazon ECS services. It has no mechanism for running unit tests, evaluating test failures, or acting as a pre-deployment quality gate. In a typical CodePipeline, CodeDeploy is used as a deploy action in a later stage, after the build and test stage has completed successfully. Trying to use CodeDeploy for unit testing would require offloading test execution to a separate service or script, which is neither its design nor a native pipeline action, making it an incorrect choice for this requirement.
Go deeper
Related to this question
About these practice questions
Courseiva writes every DOP-C02 question from scratch — 1,298 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DOP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DOP-C02 exam.