DVA-C02 - Deployment (24% of the exam) - Section 3.5

Define and deploy application infrastructure as code using AWS CloudFormation, AWS SAM and the AWS CDK.

Define and provision application infrastructure as code using AWS CloudFormation templates, AWS SAM for serverless shorthand transforms, and the AWS CDK for type-safe imperative constructs. Understand how each tool generates CloudFormation stacks and choose between them based on team familiarity and application complexity.

AWS CloudFormationAWS SAMAWS CDKInfrastructure as code

Practice question for this objective

Free sampleDeploymenthard

A developer authors an AWS SAM template that declares an AWS::Serverless::Function whose handler code lives in a local src directory and whose dependencies are listed in a requirements.txt file. They run sam build, then sam deploy, and need the local code to end up running in Lambda. Which TWO things does the SAM CLI do during this build-and-deploy flow that plain CloudFormation cannot do on its own? (Select TWO.)

  • AIt uploads the built code artifact to an Amazon S3 bucket and rewrites the CodeUri to that S3 location before creating the stack. Correct
  • BIt expands the AWS::Serverless transform into native CloudFormation resources such as the function, role and event source mappings. Correct
  • CIt provisions the Lambda execution environment directly through the Lambda API, bypassing CloudFormation stack creation entirely.
  • DIt stores the function source permanently in AWS CodeArtifact and references the package from there at runtime.
  • EIt signs the deployment artifact with AWS Signer and enforces code signing on the function automatically.
Understand that the SAM CLI both packages local code to S3 and expands the serverless transform into native resources before CloudFormation provisions the stack. CloudFormation cannot read local files or interpret AWS::Serverless shorthand. The SAM CLI bridges this by uploading the built artifact to S3, rewriting CodeUri, and relying on the SAM transform macro to expand serverless resources into native CloudFormation types that the stack can then create.

Why A is correct: sam build installs dependencies and sam deploy packages the artifact, uploads it to S3, and replaces the local CodeUri with the S3 reference CloudFormation needs.

Why B is correct: The SAM transform macro expands shorthand serverless resources into native types like AWS::Lambda::Function and AWS::IAM::Role so CloudFormation can provision them.

Why C is wrong: Tempting because SAM feels like a deployment tool, but sam deploy works through CloudFormation change sets, not direct Lambda API calls.

Why D is wrong: CodeArtifact hosts language packages for builds, not Lambda deployment artifacts; SAM uploads the zipped code to S3, not CodeArtifact.

Why E is wrong: Code signing is an optional Lambda feature you configure explicitly; the standard sam build and sam deploy flow does not sign artifacts by default.

See more DVA-C02 practice questions, answers explained.

Exam traps in Deployment

Answers that look right on this material and are not. Each one is a distractor from a different question in the DVA-C02 bank for this domain.

  • The developer must rename the resource type to AWS::Lambda::Function by hand before deploying, because CloudFormation rejects any serverless shorthand resource type outright.

    Why it is wrong: This is tempting because the function is ultimately a Lambda function, but manual rewriting defeats the point of SAM and is unnecessary once the transform expands the shorthand for you.

  • Run cdk bootstrap, which compiles the TypeScript constructs into a CloudFormation template and uploads it to the staging bucket for the scanner to inspect.

    Why it is wrong: Bootstrap provisions the toolkit stack with an asset bucket and roles in an account, so it prepares the environment rather than producing an application template.

  • Run cdk synth a second time with the verbose flag so CDK regenerates the asset staging resources inside the application template before deployment.

    Why it is wrong: Synth only emits the CloudFormation template from the construct tree, it never creates real staging resources in the account, so re-running it cannot resolve a missing bootstrap environment.

Examworthy is not affiliated with or endorsed by Amazon Web Services. Original, blueprint-aligned practice material only.