Question

Difficulty: MediumAWS CodeDeploy

A developer is configuring an AppSpec file in YAML format for an AWS CodeDeploy deployment targeting Amazon ECS. The developer needs to run a validation Lambda function immediately after the replacement task set is created, but before any traffic shifts to the new version. Which of the following configurations correctly implements this requirement?

  1. Under the hooks section, define the AfterInstall lifecycle event and specify the ARN of the validation Lambda function.Answer
  2. B
    Under the hooks section, define the ValidateService lifecycle event and specify the file path of a shell script to run the tests.
  3. C
    Under the files section, map the source file path to the ECS container path, and specify the ApplicationStart hook to trigger the Lambda function.
  4. D
    Under the hooks section, define the AfterInstall lifecycle event and use AWS Systems Manager Parameter Store to reference and execute the test script.

Answer

Under the hooks section, define the AfterInstall lifecycle event and specify the ARN of the validation Lambda function.
For an Amazon ECS deployment using AWS CodeDeploy, the AppSpec file defines lifecycle hooks under the hooks section that trigger AWS Lambda functions. The AfterInstall hook is executed after the replacement task set is created but before any traffic is routed to it. This makes it the correct place to run validation tests.

Step-by-Step Solution

1
Identify the target compute platform for the CodeDeploy deployment.
The target platform is Amazon ECS, which uses an AppSpec file containing Resources and Hooks sections.
AppSpec file structures and valid lifecycle hooks differ significantly between Amazon ECS, AWS Lambda, and EC2/on-premises compute platforms.
2
Determine the correct lifecycle hook for the validation timing requirement.
The requirement is to validate after the replacement task set is created but before any traffic shifts. The AfterInstall hook corresponds to this stage.
In ECS deployments, AfterInstall is the hook that runs immediately after the new task set is provisioned.
3
Identify how validation tasks are executed on Amazon ECS.
Validation tasks are executed by specifying a Lambda function ARN under the target lifecycle hook.
Unlike EC2 deployments which run shell scripts, ECS deployments use Lambda functions to execute validation checks.

Key Concept

AWS CodeDeploy AppSpec lifecycle hooks for Amazon ECS
Rate this question