AWS Certified Developer – Associate (DVA-C02) — Question 450
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 S3 bucket before updating the CioudFormation stack.
- D. Associate a cade signing configuration with the Lambda function before updating the CloudFormation stack.
Correct answer: B
Explanation
AWS CloudFormation only updates a resource when it detects a change in the resource's properties within the template. If the S3 object key remains the same, CloudFormation assumes no changes have occurred and will not redeploy the Lambda function. Changing the S3 object key or utilizing S3 versioning and updating the version ID in the template forces CloudFormation to recognize the update and deploy the new code.