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?
- Under the hooks section, define the AfterInstall lifecycle event and specify the ARN of the validation Lambda function.Answer
- BUnder the hooks section, define the ValidateService lifecycle event and specify the file path of a shell script to run the tests.
- CUnder the files section, map the source file path to the ECS container path, and specify the ApplicationStart hook to trigger the Lambda function.
- DUnder 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
Key Concept
AWS CodeDeploy AppSpec lifecycle hooks for Amazon ECS