Courseiva
Deployment →mediumMultiple Select

DVA-C02 Deployment Practice Question

Which THREE steps should a developer include in a CI/CD pipeline to deploy a serverless application using AWS SAM? (Choose three.)

⚠ Common exam trap

DVA-C02 often tests the misconception that manual console or CLI operations (like configuring API Gateway stages or updating aliases) belong in a CI/CD pipeline, when the exam expects the declarative SAM build/package/deploy sequence.

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

✓

Run 'sam build' to prepare the application

Option A is correct because 'sam build' compiles dependencies and prepares the application artifacts in the .aws-sam/build directory, which is the required first step before packaging or deploying a SAM application. Option C is correct because 'sam deploy' creates or updates the CloudFormation stack that provisions the serverless resources (Lambda functions, API Gateway, IAM roles, etc.) defined in the SAM template. Option E is correct because 'sam package' uploads the built artifacts to an S3 bucket and rewrites the template with the S3 locations, which is necessary for CloudFormation to access the code during deployment (in newer SAM CLI versions this is handled automatically by 'sam deploy --guided', but 'sam package' remains the explicit packaging step). Option B is incorrect because API Gateway stages are defined declaratively in the SAM template and created automatically by CloudFormation during deployment, not configured manually. Option D is incorrect because traffic shifting via Lambda aliases is an optional deployment preference configured in the SAM template (e.g., DeploymentPreference with Canary/Linear), not a manual 'aws lambda update-alias' command in 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.

  • ✓

    Run 'sam build' to prepare the application

    Why this is correct

    Correct. `sam build` is the first step in a SAM-based CI/CD pipeline. It compiles your source code, installs dependencies listed in `requirements.txt`, `package.json`, or similar manifests, and stages the runnable code under `.aws-sam/build`. It also rewrites the AWS SAM template to replace local artifact paths with the built-artifact locations, so downstream commands have a reproducible deployable bundle to consume.

  • ✗

    Manually configure API Gateway stages

    Why it's wrong here

    Incorrect. API Gateway stages are declared directly in the AWS SAM template via `Globals.Api.StageName` or API events, and CloudFormation creates and updates them automatically during `sam deploy`. Manually configuring stages in the API Gateway console is redundant, introduces drift between your infrastructure-as-code template and the live environment, and could be overwritten on the very next stack update, making the pipeline non-deterministic and difficult to audit.

  • ✓

    Run 'sam deploy' to create or update the CloudFormation stack

    Why this is correct

    Correct. `sam deploy` executes a CloudFormation stack update or creation for the SAM template, provisioning all resources including Lambda functions, API Gateway, IAM roles, and event sources. It computes a change set, gets approval if required, and then applies the changes; in a CI/CD pipeline this is the final deployment action that brings the built and packaged application into the target environment.

  • ✗

    Run 'aws lambda update-alias' to shift traffic

    Why it's wrong here

    Incorrect. `aws lambda update-alias` is an ad-hoc command for shifting traffic between Lambda versions, usually after a deployment has already occurred. In a SAM pipeline, traffic shifting is configured declaratively with `DeploymentPreference` on the `AWS::Serverless::Function` resource, and AWS CodeDeploy handles the canary or linear routing automatically. Calling `update-alias` manually in the pipeline bypasses CodeDeploy hooks, makes rollbacks more complex, and is not a recognized step in the SAM build/package/deploy workflow.

  • ✓

    Run 'sam package' to upload artifacts to S3

    Why this is correct

    Correct. `sam package` uploads the artifacts generated by `sam build` to a specified Amazon S3 bucket and outputs a packaged template with local file paths replaced by the corresponding S3 URIs. This step is essential in classic SAM pipelines because CloudFormation must fetch the Lambda code and layer bundles from S3 during deployment; it also gives you a clear, versioned artifact location and makes the packaged template portable across accounts and environments.

Quick reference

AWS S3 Storage Class Comparison

Storage ClassMin DurationRetrievalUse Case
S3 StandardNoneImmediateFrequently accessed data
S3 Standard-IA30 daysImmediateInfrequent access, rapid retrieval
S3 One Zone-IA30 daysImmediateNon-critical infrequent data
S3 Intelligent-TieringNoneImmediate–hoursUnknown or changing access patterns
S3 Glacier Instant90 daysMillisecondsArchive with instant retrieval
S3 Glacier Flexible90 daysMinutes–hoursArchive, flexible retrieval
S3 Glacier Deep Archive180 daysHoursLong-term compliance archive

About these practice questions

This DVA-C02 question is part of Courseiva's 1,135-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Amazon Web Services exam blueprint

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.