Question

Difficulty: HardDeployment Strategies

A developer is configuring a CI/CD pipeline using AWS CodeDeploy for a serverless API hosted on AWS Lambda and integrated with Amazon API Gateway. The deployment process must adhere to the following requirements:

* Production traffic must be shifted in two stages: an initial 10%10\% of traffic is routed to the new version, followed by the remaining 90%90\% after a 1515-minute evaluation period.
* Prior to routing any production traffic to the new version, a test function must run to verify that the new version can successfully write to an Amazon DynamoDB table.
* If the test function fails, or if a CloudWatch alarm for 5xx5\text{xx} errors on the new version is triggered during the evaluation period, the deployment must immediately roll back.

Which TWO actions must the developer perform to configure the deployment?

  1. Set the deployment configuration in AWS CodeDeploy to CodeDeployDefault.LambdaCanary10Percent15MinutesAnswer
  2. Specify a validation Lambda function under the BeforeAllowTraffic hook in the AppSpec file to verify database connectivityAnswer
  3. C
    Specify a validation Lambda function under the BeforeInstall hook in the AppSpec file to verify database connectivity
  4. D
    Set the deployment configuration in AWS CodeDeploy to CodeDeployDefault.LambdaLinear10PercentEvery15Minutes
  5. E
    Specify a validation Lambda function under the AfterAllowTraffic hook in the AppSpec file to verify database connectivity

Answer

Configure the deployment in AWS CodeDeploy to use the CodeDeployDefault.LambdaCanary10Percent15Minutes configuration, and specify a validation Lambda function under the BeforeAllowTraffic hook in the AppSpec file to verify database connectivity.
To satisfy the deployment requirements, the developer must configure the traffic shifting behavior and implement the pre-traffic validation test. The 'CodeDeployDefault.LambdaCanary10Percent15Minutes' configuration routes 10%10\% of the traffic to the new version of the Lambda function initially, holds it for 1515 minutes to allow for monitoring, and then routes the remaining 90%90\% of traffic. Additionally, CodeDeploy uses the AppSpec file to define deployment lifecycle hooks. For Lambda deployments, the validation test must be executed during the 'BeforeAllowTraffic' hook, which runs before traffic routing begins. If the validation function fails, CodeDeploy automatically stops the deployment and rolls back the traffic.

Step-by-Step Solution

1
Analyze the traffic shifting requirement.
The requirements dictate shifting 10%10\% of traffic initially and the remaining 90%90\% after a 1515-minute evaluation period. This matches a canary deployment configuration, specifically 'CodeDeployDefault.LambdaCanary10Percent15Minutes'.
Identifying the correct built-in configuration ensures the traffic shifting logic adheres to the specifications.
2
Determine the appropriate lifecycle hook for pre-traffic verification.
The verification must run before any production traffic shifts. The correct hook for this in Lambda deployments is 'BeforeAllowTraffic'.
Running the validation code in 'BeforeAllowTraffic' ensures that if the validation fails, traffic is never shifted, preventing service disruption.
3
Verify hook support for AWS Lambda deployments in CodeDeploy.
AWS Lambda deployments only support the 'BeforeAllowTraffic' and 'AfterAllowTraffic' hooks. EC2 hooks like 'BeforeInstall' are unsupported and will cause deployment failures.
Understanding Lambda-specific lifecycle hooks prevents configuration errors in the AppSpec file.

Key Concept

AWS CodeDeploy deployment configurations and AppSpec lifecycle hooks for AWS Lambda.
Rate this question