Point CodeUri at the local folder and deploy with sam deploy, or package the folder and use cloudformation package plus deploy
Short answer
CE Point CodeUri at the local folder, then deploy with sam deploy or with cloudformation package plus deploy.
Question
Key Takeaways
Both correct paths start by repointing CodeUri at the local application code folder, because that is what makes the change visible to the tooling: SAM then hashes and packages the code itself during sam deploy (C), or the cloudformation package command performs that packaging explicitly before deployment (E). Using aws cloudformation update-stack directly against a template whose CodeUri still points at the unchanged S3 object would fail in the same way, because the underlying artifact has not changed, and update-stack-instances in option B applies to stack instance groups across accounts rather than deploying code. Option A therefore does not address the cause.
The sam deploy command reports no changes because the CodeUri points at an S3 location whose contents are unchanged as far as CloudFormation is concerned; SAM cannot see that the code behind that fixed S3 key has been replaced. Pointing CodeUri at the local application folder lets SAM compute a content hash, package the code, and upload it as part of sam deploy, so the change is detected. The equivalent alternative is to package the local folder explicitly with the cloudformation package command and then deploy the generated template, which also produces the updated artifact.
Common mistake: Using the aws cloudformation update-stack command instead of sam deploy (A) — the failure is caused by the unchanged S3 artifact behind the CodeUri, so invoking CloudFormation directly still sees no change to the code location and the deployment remains a no-op. Using the aws cloudformation update-stack-instances command (B) — that operation updates stack instances across accounts or Regions using a prepared stack set or change set; it does not package or deploy updated function code and cannot resolve the unchanged artifact problem. The key insight both correct options share is repointing CodeUri at the local folder so packaging happens during deployment.
Expert Analysis
Why the Answer Is Correct
The root cause is that the CodeUri points at a fixed Amazon S3 location, so after uploading a new.zip to that same key CloudFormation still sees an unchanged template and reports no changes to deploy. Repointing the CodeUri property at the local application code folder fixes this, because the tooling then derives a content hash from the local files and packages and uploads the code as part of the deployment. Using the sam deploy command with a local CodeUri performs that hashing, packaging, and upload automatically and is the simplest path (C). The second correct path is to repoint CodeUri at the local folder and run the aws cloudformation package command, which performs the packaging and uploads it, followed by the aws cloudformation deploy command to deploy the resulting template (E). C and E are the correct combination.
Why the Other Options Are Wrong
A uses the aws cloudformation update-stack command instead of sam deploy. The problem is not which deployment command is invoked but that the template's CodeUri still references the same S3 object whose content has been replaced without a changed location; invoking CloudFormation directly therefore produces the same no-changes result. B uses the aws cloudformation update-stack-instances command. That operation updates stack instances across accounts or Regions from an existing prepared set or change set; it does not package or deploy updated function code, so it cannot resolve the unchanged artifact problem. C and E are correct.
Community Comment Notes
Community voted C,E (80), with A,C a 20 percent minority. trungtd explained both halves of the correct answer, that updating CodeUri to reference the local application code folder lets AWS SAM handle packaging and uploading the code to S3 during sam deploy, and that the cloudformation package command performs the equivalent packaging before deployment. jamesf confirmed that both C and E deploy the updated code reliably by ensuring changes are detected. awsaz favored A and C, but using the cloudformation update-stack command against a template whose CodeUri still points at the unchanged S3 object does not address the cause of the no-changes result.
Official Reference
- https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-deploy.html
- https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacks-export.html
These links open the official vendor documentation in a new tab.
Community Votes
80% of anonymous learners picked answer CE. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 3 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 3
-
trungtd 👍 5C. Update the CodeUri property to reference the local application code folder, AWS SAM will handle packaging and uploading the code to S3 during the "sam deploy" command execution. E. - "aws cloudformation package" command packages the local artifacts (such as Lambda function code) and uploads them to an S3 bucket. It then generates a CloudFormation template that references these artifacts. - "aws cloudformation deploy" command deploys the generated CloudFormation template. A. "aws cloudformation update-stack": without the packaging step, it won't recognize changes in the Lambda function code B. used for stack set instances D. without proper packaging of the local code, it may not detect changes correctly.
-
jamesf 👍 3Both Option C and Option E provide efficient and reliable methods to deploy updated Lambda function code using AWS SAM and CloudFormation. They address the deployment issue by ensuring that changes are recognized and appropriately handled, facilitating successful code updates in a CI/CD context. By updating the CodeUri to reference the local folder, both approaches ensure that SAM or CloudFormation acknowledges code changes, effectively resolving the "no changes to deploy" error and enabling seamless deployments.
-
awsaz 👍 2The two correct solutions to deploy the new version of the Lambda function code when sam deploy reports no changes are: A. Use the aws cloudformation update-stack command instead of the sam deploy command. C. Update the CodeUri property to reference the local application code folder. Use the sam deploy command. These approaches ensure that changes to your Lambda function code are correctly identified and deployed without encountering the "no changes to deploy" error.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All DOP-C02 Questions
Access 85 questions with complete answers and detailed explanations.
View Full DOP-C02 Practice Test →