Courseiva
SDLC AutomationeasyMultiple ChoiceObjective-mapped

DOP-C02 SDLC Automation Practice Question

A team wants to automate the deployment of a serverless application using AWS SAM. They have a template.yaml file defining Lambda functions, an API Gateway, and a DynamoDB table. Which command should they use to build and deploy the application?

⚠ Common exam trap

Test-takers frequently confuse `sam deploy` with `aws cloudformation deploy` or assume `sam deploy --guided` can handle the entire workflow without a separate build step, not realizing that `sam build` is mandatory to transform SAM-specific resources into standard CloudFormation resources and to prepare deployment artifacts.

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

sam build && sam deploy

The correct command sequence is `sam build && sam deploy` because AWS SAM requires the `sam build` command to transform the SAM template into an AWS CloudFormation template with the necessary artifact packaging, and then `sam deploy` to create or update the stack. Option C is the only choice that performs both the build (which resolves local dependencies and prepares deployment artifacts) and the deployment step, which is essential for a serverless application defined in a SAM template.

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 cloudformation deploy --template-file template.yaml

    Why it's wrong here

    This command submits the raw SAM template directly to AWS CloudFormation without first invoking `sam build` or packaging Lambda function code into deployment artifacts. Because the SAM template references local source paths and dependencies that have not been bundled, the deployment will either fail with an invalid artifact error or upload incomplete code. Furthermore, it skips the necessary transformation of SAM resources, making it an incomplete approach for a serverless application.

  • sam package --output-template-file packaged.yaml

    Why it's wrong here

    `sam package` only uploads local artifacts to Amazon S3 and produces a packaged CloudFormation template with the correct S3 URIs; it does not build the application or run the actual stack deployment. Running this alone leaves your application undeployed, as no CloudFormation stack is created or updated. You must still execute an explicit deploy command afterward, so this option is insufficient for automating the deployment process.

  • sam build && sam deploy

    Why this is correct

    This is the correct non-interactive deployment sequence for an AWS SAM application in an automated pipeline. `sam build` prepares the application by installing dependencies, compiling code, and creating the deployment artifacts required for Lambda functions and layers. `sam deploy` then packages these artifacts, uploads them to S3, and uses AWS CloudFormation to create or update the stack, all without requiring manual intervention.

  • sam deploy --guided

    Why it's wrong here

    The `--guided` flag triggers an interactive wizard that prompts for stack name, Region, parameter overrides, IAM capabilities, and confirmations before deployment. Since these prompts require manual human input, the command cannot run unattended in a CI/CD pipeline or automated script. It also does not add any build capability, so it would still fail unless the application has already been built and packaged, making it unsuitable for this automation use case.

Visual reference

Client Recursive Resolver Root DNS (13 root servers) TLD DNS (.com, .org, …) Authoritative example.com query IP addr answer

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

Courseiva writes every DOP-C02 question from scratch — 251 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 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.