Question

Difficulty: Very hardDeployment Strategy Design

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 10%10\% 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 100%100\% if successful.
* Monitor API Gateway-level integration latency and HTTP 5XX5\text{XX} 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 5XX5\text{XX} error rate exceeds 0.1%0.1\% or if the average integration latency of the canary exceeds 250 ms250\text{ ms} during the validation period.

Which deployment strategy meets these requirements with the lowest operational complexity?

  1. A
    Create 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.
  2. B
    Deploy 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.
  3. 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
  4. D
    Deploy 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.

Answer

Configure the API Gateway stage to use a Canary release with a 10% traffic weight, override stage variables to point to the new Lambda version's alias, monitor the canary-specific CloudWatch metrics, and trigger a Lambda function to delete the canary settings if alarms are breached.
The deployment strategy using API Gateway stage canary with a 10% traffic weight and stage variable overrides is the most optimal. API Gateway stage canaries allow simultaneous testing of API Gateway configuration changes and Lambda function updates by overriding the stage variable (e.g., lambdaAlias) to point to the new Lambda version's alias. API Gateway automatically publishes dedicated metrics with the 'Canary=true' dimension, allowing the monitoring of canary-specific HTTP 5XX error rates and integration latency without dilution. If these metrics exceed the threshold, a CloudWatch Alarm triggers a Lambda function that calls the API Gateway UpdateStage API to delete the canary, initiating a near-instant rollback of all traffic back to the production version.

Step-by-Step Solution

1
Configure the API Gateway REST API stage to enable a Canary release with 10% traffic, and configure stage variables such that the main stage points to the production Lambda alias while the canary override points to the new Lambda version alias.
API Gateway routes 90% of requests to the production API configuration and Lambda alias, and 10% of requests to the new API configuration and new Lambda version alias.
This allows simultaneous testing of API Gateway configuration changes and backend Lambda code changes on a fraction of production traffic.
2
Create CloudWatch Alarms on the API Gateway metrics filtered by the dimensions Stage and Canary (Canary=true) for 5XXError and IntegrationLatency.
Alarms are configured to monitor the isolated performance of only the canary traffic, preventing metric dilution from the healthy production traffic.
Isolating canary metrics ensures that even small anomalies in the new deployment (e.g., a 1% error rate on the canary) trigger alarms immediately rather than being masked by the production traffic.
3
Configure the CloudWatch Alarms to trigger an AWS Lambda function that calls the API Gateway UpdateStage API (or update-stage CLI command) to delete the canary settings.
If an alarm breaches, the canary configuration is removed from the stage, immediately reverting 100% of traffic to the stable production version.
Deleting the canary release settings on the stage rolls back the deployment instantly, satisfying the 2-minute recovery SLA.
4
Configure an automated Step Functions workflow or CI/CD pipeline to promote the API Gateway canary to the production stage after 30 minutes of successful execution without any alarm triggers.
The canary deployment configuration is promoted to the production stage, shifting 100% of traffic to the new version.
This automates the promotion phase, completing the deployment process with minimal operational overhead.

Key Concept

API Gateway Canary releases combined with stage variable overrides and isolated CloudWatch metric monitoring enable safe, automated canary deployments and rapid rollbacks for both API configurations and backend Lambda code.
Estimated Time:3m 0s
Rate this question