Courseiva
Development with AWS ServicesmediumMultiple ChoiceObjective-mapped

DVA-C02 Development with AWS Services Practice Question

A company is using AWS CodePipeline to automate its CI/CD pipeline. The pipeline has a build stage that uses AWS CodeBuild. The developer wants to run unit tests and only proceed to the deploy stage if the tests pass. Which configuration should the developer use to achieve this?

⚠ Common exam trap

The trap here is that candidates may over-engineer a solution (like Lambda or manual approval) when the native failure propagation in CodePipeline already handles the requirement automatically.

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

Configure the build stage to run tests and fail the build if tests fail; CodePipeline will automatically stop.

AWS CodeBuild can be configured to run unit tests as part of the build phase. If any test fails, CodeBuild exits with a non-zero status, causing the build to fail. CodePipeline automatically stops the pipeline execution when a stage fails, preventing the deploy stage from running. This is the native and simplest way to gate deployment on test success.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Configure a manual approval step before the deploy stage.

    Why it's wrong here

    A manual approval step in CodePipeline requires a human to explicitly approve the transition to the next stage, regardless of automated test outcomes. This mechanism does not provide an automated halt based on test failures, as it necessitates human intervention to evaluate results and make a decision, which contradicts the goal of an automated CI/CD pipeline stopping automatically upon test failure.

  • Configure Amazon CloudWatch alarms to stop the pipeline if tests fail.

    Why it's wrong here

    Amazon CloudWatch alarms are designed for monitoring metrics and logs, triggering notifications or invoking other AWS services like Lambda. While a CloudWatch alarm could detect a test failure metric, it lacks the native capability to directly stop a CodePipeline execution. Implementing this would require an additional Lambda function to interpret the alarm and then call CodePipeline APIs, adding unnecessary complexity and an indirect control flow.

  • Configure the build stage to run tests and fail the build if tests fail; CodePipeline will automatically stop.

    Why this is correct

    The AWS CodeBuild action within a CodePipeline build stage is specifically designed to execute build commands and tests. If any command within the CodeBuild `buildspec.yml` exits with a non-zero status, CodeBuild reports a failure to CodePipeline. CodePipeline then automatically recognizes this failed action, stops the current pipeline execution, and prevents any subsequent stages, such as deployment, from being initiated, ensuring a 'fail fast' approach.

  • Configure AWS Lambda to invoke a function that checks test results and manually stops the pipeline.

    Why it's wrong here

    Configuring a Lambda function to manually stop the pipeline introduces an external, event-driven check that does not integrate with CodePipeline’s native transition logic; the correct approach uses a CodeBuild test command that automatically fails the build phase, preventing the deploy stage from starting. This option is tempting because Lambda can perform custom validation logic, and in scenarios requiring asynchronous approval gates or external system verification, invoking a Lambda function to halt a pipeline is a valid pattern.

About these practice questions

Courseiva writes every DVA-C02 question from scratch — 724 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 →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DVA-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 DVA-C02 exam.