Question

Difficulty: MediumAWS CodeDeploy

A developer is configuring a canary deployment for an AWS Lambda function using AWS CodeDeploy. The deployment must run a test Lambda function to validate the deployment before shifting traffic, and another test Lambda function to run post-deployment validation checks after all traffic has been shifted to the new version. Which two configuration steps must the developer perform to meet these requirements?

  1. Define the validation Lambda functions under the BeforeAllowTraffic and AfterAllowTraffic hooks in the AppSpec file.Answer
  2. Attach a policy to the CodeDeploy service role that allows the lambda:InvokeFunction action on the validation Lambda functions, and ensure its trust policy allows the codedeploy.amazonaws.com service principal.Answer
  3. C
    Define the validation Lambda functions under the BeforeInstall and AfterInstall hooks in the AppSpec file.
  4. D
    Modify the trust policy of the validation Lambda functions' execution role to allow codedeploy.amazonaws.com to assume the role.
  5. E
    Store the validation Lambda function ARNs in AWS Secrets Manager and reference them in the resources section of the AppSpec file to dynamically retrieve them during deployment.

Answer

Define the validation Lambda functions under the BeforeAllowTraffic and AfterAllowTraffic hooks in the AppSpec file, and attach a policy to the CodeDeploy service role that allows the lambda:InvokeFunction action on the validation Lambda functions while ensuring its trust policy allows the codedeploy.amazonaws.com service principal.
The correct options properly configure the deployment lifecycle hooks for AWS Lambda (BeforeAllowTraffic and AfterAllowTraffic) in the AppSpec file and grant the required invoke permissions to the CodeDeploy service role.

Step-by-Step Solution

1
Identify the target compute platform and the required hooks.
The target is AWS Lambda. The appropriate lifecycle hooks for running validation tests before traffic shifting starts and after it completes are BeforeAllowTraffic and AfterAllowTraffic.
Choosing the correct lifecycle hooks ensures CodeDeploy triggers the validation tests at the correct points in the deployment process.
2
Configure the CodeDeploy service role permissions.
Ensure the CodeDeploy service role has a trust relationship with codedeploy.amazonaws.com and contains permissions for lambda:InvokeFunction targeting the test Lambda functions.
CodeDeploy must be authorized to assume its role and invoke the external Lambda functions designated as validation hooks.

Key Concept

AWS CodeDeploy lifecycle hooks for Lambda deployments and their associated IAM permissions.
Rate this question