Courseiva
SDLC Automation →mediumMultiple Choice

DOP-C02 SDLC Automation Practice Question

An organization uses AWS CodePipeline with a multi-branch strategy. They want to run unit tests on every push to any branch, but only deploy to production on pushes to the 'main' branch. What is the most efficient way to achieve this?

⚠ Common exam trap

Many candidates think they need separate pipelines per branch (Option C) or a manual promotion step (Option B), but AWS CodePipeline supports branch filtering natively via webhook event patterns and custom conditions, making a single pipeline the most efficient choice.

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 a single pipeline with a source action that triggers on all branches, then use a 'branch' condition on the deployment stage to only proceed if the branch is 'main'.

AWS CodePipeline supports a single pipeline with a source action configured to trigger on all branches (e.g., using a webhook event filter for 'refs/heads/*'). You can then add a 'branch' condition on the deployment stage using a Lambda function or a manual approval action that checks the branch name, ensuring only pushes to 'main' proceed to production. This approach avoids duplicating pipelines while still running unit tests on every push.

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 single pipeline with a source action that triggers on all branches, then use a 'branch' condition on the deployment stage to only proceed if the branch is 'main'.

    Why this is correct

    This option uses a single CodePipeline execution triggered by all branch updates, and then applies a stage condition such as #{SourceVariables.BranchName} == 'main' on the deployment action. Test and build stages still run for every branch, but non-main branches are skipped at the deployment stage, so no production release occurs for feature branches. This minimizes pipeline infrastructure, reduces maintenance, and keeps the automation fully managed inside the pipeline.

  • ✗

    Use a single pipeline with a source action that triggers on all branches, and deploy to a test environment for all branches, then promote to production manually.

    Why it's wrong here

    Automatically deploying every branch to a test environment wastes compute and storage and can cause concurrent executions to contend for the same staged resources, especially with many short-lived feature branches. Requiring a manual promotion to production injects human latency and error risk into the CD process, bypasses CodePipeline's built-in approval gates, and means developers must remember to re-trigger or resume the execution, undermining the CI/CD feedback loop.

  • ✗

    Create separate pipelines for each branch, each with its own test and deploy stages.

    Why it's wrong here

    Creating a dedicated pipeline for each branch multiplies your pipeline definitions, CloudFormation stacks, IAM roles, and associated notification rules, and every new branch requires manual pipeline creation before the developer receives any CI/CD support. Such a design becomes quickly unmanageable for a team using ephemeral or feature branches and makes it easy for stage configurations to drift between pipelines, so a fix applied to one branch's pipeline may be missing from another.

  • ✗

    Use a single pipeline with a source action that only triggers on the 'main' branch, and run tests in a separate system.

    Why it's wrong here

    With the pipeline only listening for changes on main, feature-branch commits never trigger a pipeline execution, so there is no automated run of unit tests, static analysis, or build validation until code is merged; integration problems are detected too late. Running tests in an external system breaks the correlation between a specific commit and its test results, because the external system is unaware of CodePipeline's source variables and artifact handling, giving developers a slower and less transparent feedback path.

Quick reference

Cloud Service Model Comparison

ModelYou ManageProvider ManagesExamples
IaaSOS, runtime, apps, dataHardware, hypervisor, networkingEC2, Azure VMs, GCP Compute Engine
PaaSApps and dataOS, runtime, middleware, hardwareElastic Beanstalk, Azure App Service
SaaSData and settings onlyEverything elseMicrosoft 365, Salesforce, Workday
FaaS / ServerlessFunction code onlyInfra, scaling, runtimeLambda, Azure Functions, Cloud Run
CaaSContainers and appsKubernetes, OS, hardwareEKS, AKS, GKE

About these practice questions

One of 1,298 original DOP-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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 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.