AWS Certified Developer – Associate — Question 355
A developer is implementing a serverless application by using AWS CloudFormation to provision Amazon S3 web hosting, Amazon API Gateway, and AWS Lambda functions. The Lambda function source code is zipped and uploaded to an S3 bucket. The S3 object key of the zipped source code is specified in the Lambda resource in the CloudFormation template.
The developer notices that there are no changes in the Lambda function every time the CloudFormation stack is updated.
How can the developer resolve this issue?
Answer options
- A. Create a new Lambda function alias before updating the CloudFormation stack.
- B. Change the S3 object key or the S3 version in the CloudFormation template before updating the CloudFormation stack.
- C. Upload the zipped source code to another $3 bucket before updating the CloudFormation stack.
- D. Associate a code signing configuration with the Lambda function before updating the CloudFormation stack.
Correct answer: B
Explanation
AWS CloudFormation only updates a Lambda function when it detects a change in the template's properties for that resource. If the S3 object key or version remains identical, CloudFormation assumes no changes are needed, even if the file in S3 has been overwritten. Modifying the key or specifying a new S3 object version forces CloudFormation to recognize the update and deploy the new code.