AWS SAM Template - Lambda Function Deployment with AWS CodeDeploy

Serverless Application Model (SAM) Template for Lambda Function Deployment with CodeDeploy

Prev Question Next Question

Question

You have written an AWS Serverless Application Model (AWS SAM) template to create a Lambda function.

As AWS SAM service has integrated with AWS CodeDeploy to ensure safe Lambda deployments, you prefer to shift users to the new version gradually.

A piece of template is as below:

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer - B.

If SAM is used to deploy serverless application, it has integrated with CodeDeploy service to ensure safe deployment.

CodeDeploy has supported three types of deployment for Lambda function which are Canary, Linear and All-at-once.

For the deployment configuration details of CodeDeploy on Lambda Compute Platform, refer to.

ttps://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-configurations.html.

Option A is incorrect: Because as long as a preconfigured CloudWatch alarm is triggered, CodeDeploy rolls back the deployment.

Option B is CORRECT: Because Canary10Percent5Minutes belongs to Canary deployment.

It means that 10 percent of the whole traffic is shifted to the new software release at once.

Then all the other traffic is shifted after 5 minutes.

Option C is incorrect: Because for CodeDeploy service, the pre-hook and post-hook tests validate the sanity of the deployment status.

If anything goes wrong with the hooks, the deployment will be rolled back.

This is also a method to prevent further damage on the application from a problematic deployment.

Option D is incorrect: Same reason as Option.

C.

The question describes a scenario where a AWS SAM template is used to create a Lambda function and the developer wants to deploy the new version of the function gradually using AWS CodeDeploy. The question provides a piece of template code and asks which statement is true about CodeDeploy's behavior.

The provided template code likely includes CodeDeploy deployment settings, including deployment traffic shifting and validation hooks. Here are explanations of each answer choice:

A. If an alarm such as AliasErrorMetricAlarm appears, CodeDeploy does not roll back the deployment. This statement is not true. CodeDeploy will roll back a deployment if a CloudWatch alarm is triggered during the deployment. The alarm could be related to any of the deployment's metrics, not just AliasErrorMetricAlarm.

B. 10 percent of the traffic is shifted to the new version all at once. Then the remaining 90 percent of traffic is shifted to the new version 5 minutes later. This statement is a valid traffic shifting strategy in CodeDeploy. It means that when the deployment is initiated, 10% of traffic will immediately go to the new version, and then after 5 minutes, the remaining 90% of traffic will be shifted to the new version. This allows for gradual testing of the new version with live traffic.

C. If PreTrafficLambdaForValidation has failed, the deployment is not rolled back. This statement is true. The PreTrafficLambdaForValidation hook is a validation check that occurs before traffic is shifted to the new version. If this validation fails, the deployment will be halted but not rolled back. This allows the developer to investigate and fix the issue before attempting to deploy again.

D. If PostTrafficLambdaForValidation has failed, the deployment is not rolled back. This statement is not true. The PostTrafficLambdaForValidation hook is a validation check that occurs after traffic is shifted to the new version. If this validation fails, the deployment will be rolled back to the previous version to prevent negative impact on users. This allows the developer to investigate and fix the issue before attempting to deploy again.

Therefore, the correct answer is C. If PreTrafficLambdaForValidation has failed, the deployment is not rolled back.