A company is designing a deployment pipeline for a serverless API that uses Amazon API Gateway and AWS Lambda. The new deployment strategy must meet the following requirements:
- Shifting traffic to the new Lambda version must be done gradually, routing of the traffic for a -minute verification period before routing the remaining of the traffic.
- A health-check suite must execute testing against the new Lambda version before any production traffic is routed to it.
- The deployment must automatically roll back if the Lambda function's error rate spikes or if the health-check suite fails.
Which combination of actions must the solutions architect take to implement this deployment strategy? (Select TWO.)
- Configure the AWS CodeDeploy deployment group to use the CodeDeployDefault.LambdaCanary10Percent15Minutes deployment configuration, and define a BeforeAllowTraffic lifecycle hook in the AppSpec file that points to a validation Lambda function.Answer
- Create a CloudWatch alarm that monitors the Errors metric of the Lambda function, and configure the CodeDeploy deployment group to automatically roll back when this alarm is triggered.Answer
- CConfigure the AWS CodeDeploy deployment group to use the CodeDeployDefault.LambdaLinear10PercentEvery15Minutes deployment configuration, and define an AfterAllowTraffic lifecycle hook in the AppSpec file to execute the health-check suite.
- DCreate an AWS Lambda alias pointing to both the active and the new Lambda versions with a routing weight, and configure a Route 53 weighted alias record to shift traffic after minutes.
- ECreate a CloudWatch alarm that monitors API Gateway IntegrationLatency and associate it with a CloudFormation stack rollback trigger to automatically revert the Lambda function version alias.
Answer
Configure the AWS CodeDeploy deployment group to use the canary deployment configuration with a BeforeAllowTraffic lifecycle hook, and configure a CloudWatch alarm on the Lambda Errors metric to trigger an automatic rollback.
To implement the gradual traffic shifting strategy, the canary deployment configuration routes of traffic to the new Lambda version for minutes, then shifts the remaining of traffic instantly. The BeforeAllowTraffic hook runs before any production traffic is shifted to the new Lambda function version, making it the correct lifecycle phase to execute the health-check suite. To support automated rollbacks based on failures, CodeDeploy natively supports CloudWatch alarms. If the CloudWatch alarm monitoring the Lambda Errors metric triggers during the deployment, CodeDeploy immediately halts the deployment and rolls back the alias to the previous stable version.
Step-by-Step Solution
Key Concept
Canary deployment strategy with CodeDeploy lifecycle validation hooks and CloudWatch rollback alarms for serverless workloads