Question

Difficulty: MediumAWS CodeDeploy

A development team is deploying an updated AWS Lambda function using AWS CodeDeploy with a linear traffic-shifting configuration. Before any production traffic is routed to the new function version, the deployment process must run a separate validation Lambda function to perform smoke tests.

Which lifecycle hook must be specified in the `Hooks` section of the `appspec.yml` file to execute the validation function?

  1. A
    BeforeInstall
  2. B
    BeforeAllowTestTraffic
  3. BeforeAllowTrafficAnswer
  4. D
    ValidateService

Answer

BeforeAllowTraffic
The BeforeAllowTraffic lifecycle hook is one of the two hooks supported for AWS Lambda deployments in AWS CodeDeploy. It executes before traffic routing to the new Lambda version starts, which is the correct phase to run a validation function.

Step-by-Step Solution

1
Identify the target compute platform for the AWS CodeDeploy deployment.
The target compute platform is AWS Lambda.
Deployment lifecycle hooks in AWS CodeDeploy are platform-specific and differ between EC2/on-premises, Amazon ECS, and AWS Lambda.
2
Determine the required phase of the deployment for running the validation test.
The validation test must run before any production traffic is shifted to the new Lambda version.
Running tests early prevents routing production traffic to a broken or misconfigured version.
3
Select the appropriate Lambda-supported lifecycle hook from the available options.
The BeforeAllowTraffic hook is the correct hook that executes before traffic shifting begins.
AWS Lambda deployments in CodeDeploy support only BeforeAllowTraffic and AfterAllowTraffic hooks.

Key Concept

AWS CodeDeploy supports a specific set of deployment lifecycle hooks for AWS Lambda, which are different from those used for Amazon ECS and EC2. Specifically, only BeforeAllowTraffic and AfterAllowTraffic are valid for Lambda deployments.
Estimated Time:1m 0s
Rate this question