A company is designing a deployment pipeline for a high-transaction serverless application that uses Amazon API Gateway (REST API) and AWS Lambda. The application is accessed via a custom domain. The upcoming release contains both API Gateway resource configuration changes and Lambda function updates. The deployment process must meet the following requirements:
* Route exactly of the live production traffic to the new version of the API and Lambda function for a 30-minute validation period, then automatically promote it to if successful.
* Monitor API Gateway-level integration latency and HTTP error rates specifically for the canary traffic, isolated from the main production traffic.
* Automatically roll back all changes to the previous stable state within 2 minutes if the canary error rate exceeds or if the average integration latency of the canary exceeds during the validation period.
Which deployment strategy meets these requirements with the lowest operational complexity?
- ACreate a new Lambda version and configure AWS CodeDeploy to shift traffic using the CodeDeployDefault.LambdaCanary10Percent30Minutes deployment configuration on the Lambda function's production alias. Configure API Gateway to integrate with this alias. Create CloudWatch Alarms on the API Gateway stage-level 5XXError and IntegrationLatency metrics, and associate these alarms with the CodeDeploy deployment group to trigger automatic rollback.
- BDeploy the new API Gateway configuration and Lambda function to a new API Gateway stage named canary. Configure Route 53 with weighted routing records under the custom domain name, pointing 90% of traffic to the prod stage and 10% of traffic to the canary stage. Create CloudWatch Alarms on the canary stage's 5XXError and IntegrationLatency metrics. Configure an AWS Lambda function triggered by the alarms to change the Route 53 weight for the prod stage to 100% if an alarm triggers.
- Configure the API Gateway stage to use a Canary release with a 10% traffic weight. Define a stage variable in API Gateway pointing to a Lambda alias, and configure the stage's canary settings to override the stage variable to point to the new Lambda version's alias. Create Amazon CloudWatch Alarms on the API Gateway canary metrics (5XXError and IntegrationLatency with the Stage and Canary dimensions). Configure an AWS Lambda function triggered by the alarms to call the API Gateway UpdateStage API to delete the canary settings to initiate rollback, and use an automated workflow to promote the canary to production after 30 minutes of successful monitoring.Answer
- DDeploy the changes using AWS CloudFormation. In the CloudFormation template, update the API Gateway stage resource to enable a CanarySetting of 10% traffic. Configure CloudFormation Rollback Triggers using CloudWatch Alarms on the API Gateway stage-level 5XXError and IntegrationLatency metrics. If the alarms trigger during the stack update, CloudFormation will roll back the stack. Otherwise, manually perform a second stack update after 30 minutes to promote the canary.