A developer uses AWS SAM to prototype a Lambda function. The SAM template's AWS::Serverless::Function has CodeUri pointing to an S3 location. The developer packaged the function as package.zip, uploaded it to the S3 location, and ran sam deploy. After updating the function code and repeating those same steps (uploading to the same S3 key), sam deploy fails saying "no changes to deploy." Which approaches will deploy the updated code? (Choose two.)
Choose an answer
Tap an option to check your answer.
Correct answer: Change the CodeUri property to point to the local code folder and run sam deploy., Change the CodeUri property to point to the local code folder, run aws cloudformation package to upload artifacts to S3, then use aws cloudformation deploy..
Why this is the answer
The sam deploy command, when CodeUri points to an S3 location, checks for changes in the SAM template itself, not the content of the S3 object. If the S3 key remains the same, SAM perceives no template change and thus no deployment is triggered. To deploy updated code, you must either: 1. Change CodeUri to point to the local code folder: sam deploy will then automatically package and upload the local code to a new S3 location (with a unique version hash) and update the CloudFormation stack. 2. Use aws cloudformation package and aws cloudformation deploy: This two-step process explicitly packages your local code, uploads it to S3, and then deploys the updated CloudFormation template. Using aws cloudformation update-stack directly would require manually updating the S3 object's ETag or version in the CloudFormation template, which is cumbersome. update-stack-instances is for CloudFormation StackSets, not individual stacks. Creating and executing a CloudFormation change set after changing CodeUri to a local folder is redundant, as sam deploy handles this automatically.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed