Which Two Commands Deploy an Existing AWS SAM Template?
A developer is creating a script to automate the deployment process for a serverless application. The developer wants to use an existing AWS Serverless Application Model (AWS SAM) template for the application. What should the developer use for the project? (Choose two.)
Community Votes
60% of anonymous learners picked answer AB. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
The question tests that both SAM CLI and CloudFormation CLI commands can deploy SAM templates; the trap is choosing manual S3 uploads, single-function Lambda APIs, or Serverless Application Repository calls that cannot deploy a SAM application.
An existing AWS SAM template can be automated for deployment with either the SAM CLI pair (sam package + sam deploy) or the CloudFormation CLI pair (aws cloudformation package + aws cloudformation deploy), because SAM templates are transformed and deployed through CloudFormation. The community majority (60%) and the top-liked comment support AB as the correct pair.
The most common wrong pick is E (manual ZIP to S3 + create-stack), often paired with B, because candidates assume SAM templates require the SAM CLI or manual packaging; in reality aws cloudformation package/deploy natively handles SAM templates and their local artifact references.
Community Discussion (3 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
An AWS SAM template is ultimately processed by CloudFormation, so both toolchains can deploy it in a script.aws cloudformation package uploads the local artifacts referenced by the template (such as CodeUri) to Amazon S3 and outputs a packaged template, and aws cloudformation deploy then creates or updates the stack with the SAM transform — making A valid. Similarly, sam package and sam deploy are the AWS SAM CLI equivalents of those CloudFormation commands, making B equally valid. The most-liked comment ([2], 3 likes) states 'the answer is A B', which matches the majority vote distribution (AB: 60 vs BE: 40).Why the Other Options Are Wrong
C fails becauseaws lambda update-function-code only updates the code of an existing function and cannot create an application, and merely copying the raw SAM template to S3 with aws s3 cp deploys nothing. D uses aws serverlessrepo create-application, which publishes an app to the Serverless Application Repository rather than deploying it as a stack. E skips the required packaging step: a SAM template referencing local artifacts fails in create-stack unless the artifacts are uploaded and the CodeUri values rewritten, which is exactly what the package commands automate. Commenters who chose E ([1]) overlook that the manual ZIP + create-stack flow does not correctly resolve the SAM template's local references.Community Comment Notes
Comment [2] ('the answer is A B') carries the highest likes (3) and aligns with the 60% majority vote for AB. Comment [1] argues for BE with 2 likes, reflecting the minority belief that SAM templates mandate the SAM CLI — but the CloudFormation CLI fully supports SAM transforms. Comment [3]'s CE suggestion has no likes and is clearly incorrect since neither option can deploy a SAM application end to end.Official Reference
Exam Strategy
Treat sam package/sam deploy and aws cloudformation package/aws cloudformation deploy as interchangeable pairs for SAM templates, so a two-answer question can legitimately include both pairs. Eliminate any option that uses a single-function API like update-function-code or publishes to the Serverless Application Repository, since neither deploys a full application. When a 'Choose two' question offers two equivalent CLI command pairs, those are usually the intended answers.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →