Question

Difficulty: HardDeployment Strategies

A developer is configuring a CI/CD pipeline to deploy updates to an AWS Lambda function that is integrated with an Amazon API Gateway REST API. The developer needs to implement a deployment strategy that routes 10%10\% of the incoming API traffic to the new Lambda version for a 2020-minute evaluation period. If any 5xx5\text{xx} errors are detected during this period, the traffic must automatically and immediately roll back to the stable version. The deployment must not require changes to the API Gateway stage configuration.

Which two configurations should the developer implement to meet these requirements?

  1. Configure the API Gateway integration to target a Lambda function alias instead of a specific version ARN or the LATESTLATEST qualifier.Answer
  2. Configure an AWS CodeDeploy deployment group to use the deployment configuration named `CodeDeployDefault.LambdaCanary10Percent20Minutes` and associate it with a CloudWatch alarm monitoring API Gateway 5xx5\text{xx} errors.Answer
  3. C
    Configure API Gateway stage canary settings, setting the canary traffic percentage to 10%10\% and mapping the canary to the new Lambda version ARN.
  4. D
    Set the deployment configuration in AWS CodeDeploy to `CodeDeployDefault.LambdaLinear10PercentEvery2Minutes` and associate the deployment group with a CloudWatch alarm monitoring API Gateway 5xx5\text{xx} errors.
  5. E
    Publish the new Lambda version and update the API Gateway integration to point to the new version's ARN directly, relying on Lambda's built-in routing rules to shift 10%10\% of the traffic.

Answer

To meet the requirements, the developer must configure the API Gateway integration to target a Lambda function alias instead of a specific version ARN or the LATESTLATEST qualifier, and configure an AWS CodeDeploy deployment group to use the deployment configuration named `CodeDeployDefault.LambdaCanary10Percent20Minutes` and associate it with a CloudWatch alarm monitoring API Gateway 5xx5\text{xx} errors.
Targeting a Lambda function alias from API Gateway allows AWS CodeDeploy to shift traffic at the Lambda level by shifting the alias routing configuration between two versions. Selecting the `CodeDeployDefault.LambdaCanary10Percent20Minutes` deployment configuration routes exactly 10%10\% of traffic to the new version for a 2020-minute window while monitoring the associated CloudWatch alarms. If the alarm for 5xx5\text{xx} errors fires, CodeDeploy automatically rolls back the alias configuration to route all traffic back to the stable version, achieving an automated rollback.

Step-by-Step Solution

1
Establish version-level addressing for the Lambda function.
Configure the API Gateway integration to point to a Lambda function alias (e.g., `prod`).
Lambda version routing requires an alias. Pointing directly to a version ARN prevents CodeDeploy from dynamically shifting weights because versions are immutable.
2
Select the deployment configuration that matches the traffic-shifting requirements.
Identify `CodeDeployDefault.LambdaCanary10Percent20Minutes` as the correct configuration.
The scenario requires routing a constant 10%10\% of traffic to the new version for a 2020-minute evaluation period before shifting 100%100\% of traffic, which matches the definition of this canary configuration.
3
Configure automated rollback triggers.
Associate the CodeDeploy deployment group with a CloudWatch alarm monitoring API Gateway 5xx5\text{xx} errors.
If 5xx5\text{xx} errors occur during the 2020-minute evaluation, the alarm triggers and CodeDeploy immediately rolls back the alias routing weights to point 100%100\% of traffic back to the stable version.

Key Concept

Lambda Canary Deployments with AWS CodeDeploy
Estimated Time:2m 0s
Rate this question