Question

Difficulty: HardDeployment Strategy Design

A financial services company is migrating its backend payment processing microservice to a serverless architecture using Amazon API Gateway and AWS Lambda. Due to strict compliance and risk mitigation guidelines, any deployment of a new code version must be exposed to production traffic gradually. Specifically, the new version must receive 10% of traffic initially, and then the remaining traffic must be routed in equal increments of 10% every 10 minutes. If the payment processing latency exceeds 500 ms or if the Lambda error rate exceeds 1% at any point during the deployment, the deployment must automatically and immediately roll back. Additionally, the Lambda function relies on a database connection pool that must be fully initialized and pre-warmed before the new version starts serving any production traffic to prevent connection timeout errors during the initial traffic shift. Which deployment strategy should the solutions architect implement to meet these requirements with the least operational complexity?

  1. Deploy the Lambda function using AWS CloudFormation and configure the AWS::Lambda::Alias resource with a DeploymentPreference type set to CodeDeployDefault.LambdaLinear10PercentEvery10Minutes. Associate the deployment with CloudWatch Alarms for function errors and latency. Define a BeforeAllowTraffic lifecycle hook in the AppSpec file to execute a validation Lambda function that pre-warms the database connection pool.Answer
  2. B
    Deploy the Lambda function using AWS CloudFormation and configure the AWS::Lambda::Alias resource with a DeploymentPreference type set to CodeDeployDefault.LambdaCanary10Percent10Minutes. Associate the deployment with CloudWatch Alarms for function errors and latency. Define a BeforeAllowTraffic lifecycle hook in the AppSpec file to execute a validation Lambda function that pre-warms the database connection pool.
  3. C
    Deploy the Lambda function using AWS CloudFormation and configure the AWS::Lambda::Alias resource with a DeploymentPreference type set to CodeDeployDefault.LambdaLinear10PercentEvery10Minutes. Associate the deployment with CloudWatch Alarms for function errors and latency. Define an AfterAllowTraffic lifecycle hook in the AppSpec file to execute a validation Lambda function that pre-warms the database connection pool.
  4. D
    Deploy the new Lambda function version and configure an API Gateway canary release with a 10% traffic weighting. Create an AWS Step Functions state machine that invokes a Lambda function to update the API Gateway deployment stage weights by 10% every 10 minutes. Use a second Lambda function to monitor the CloudWatch metrics and programmatically delete the canary configuration if thresholds are exceeded.

Answer

Deploy the Lambda function using AWS CloudFormation with the AWS::Lambda::Alias DeploymentPreference set to CodeDeployDefault.LambdaLinear10PercentEvery10Minutes, configured with CloudWatch Alarms for rollback, and a BeforeAllowTraffic lifecycle hook to run a validation function that pre-warms the database connection pool.
The optimal solution uses AWS CloudFormation to manage the serverless deployment via AWS CodeDeploy. A linear shifting strategy (CodeDeployDefault.LambdaLinear10PercentEvery10Minutes) satisfies the requirement of routing traffic in equal 10% increments every 10 minutes. Using a BeforeAllowTraffic lifecycle hook allows a validation Lambda function to run and initialize the database connection pool before the actual traffic starts shifting, preventing latency or connection timeouts for the first users. Integrating CloudWatch Alarms with CodeDeploy provides automated rollback capabilities.

Step-by-Step Solution

1
Analyze the traffic shifting requirement
Identify that the system requires shifting traffic in 10% increments every 10 minutes until completed, which matches a linear deployment configuration (CodeDeployDefault.LambdaLinear10PercentEvery10Minutes) rather than a canary configuration.
Choosing the correct deployment configuration configuration is essential for meeting compliance and risk mitigation guidelines.
2
Determine the proper lifecycle hook for database pre-warming
Identify that the database connection pool must be warm before the new version begins serving any production traffic, which requires the BeforeAllowTraffic lifecycle hook.
The BeforeAllowTraffic hook runs a validation Lambda function to pre-warm resources before any production traffic is shifted to the new alias. Using AfterAllowTraffic would execute too late, causing connection timeouts during the deployment.
3
Configure the automated rollback mechanism
Associate CloudWatch Alarms for Lambda error rate and latency to the CodeDeploy deployment group.
If any alarm triggers during the deployment, CodeDeploy will automatically stop the deployment and redirect 100% of traffic back to the original stable version, satisfying the rollback requirement.

Key Concept

AWS CodeDeploy Lambda Traffic Shifting and Lifecycle Hooks
Estimated Time:3m 0s
Rate this question