A development team is setting up a continuous delivery pipeline using AWS CodeDeploy for a microservice hosted on Amazon Elastic Container Service (Amazon ECS). The team wants to ensure that a validation test suite is executed immediately after the new container tasks are registered and test traffic is routed to them, but before any production traffic is shifted. Additionally, they want to execute a notification task once the production traffic has been completely transitioned.
Which actions must the developer take to achieve this deployment workflow? (Select TWO.)
- Define the AfterAllowTestTraffic hook in the appspec.yaml file to invoke a Lambda function that executes the validation tests.Answer
- Define the AfterAllowTraffic hook in the appspec.yaml file to invoke a Lambda function that executes the notification task.Answer
- CDefine the ApplicationStart and ApplicationStop hooks in the appspec.yaml file to run the validation tests and the notification task.
- DUpdate the trust policy of the Amazon ECS task execution role to trust the codedeploy.amazonaws.com service principal.
- EStore the notification service credentials in AWS Systems Manager Parameter Store as a Standard Parameter with a String data type for retrieval by the validation script.
Answer
To configure this ECS deployment workflow, the developer must define the AfterAllowTestTraffic hook in the appspec.yaml file to execute the validation tests, and define the AfterAllowTraffic hook to run the post-traffic routing notification task.
For an Amazon ECS deployment, CodeDeploy uses a specific set of hooks. The 'AfterAllowTestTraffic' hook runs after the replacement tasks are created and test traffic is routed to them, making it the ideal stage for running integration/validation tests. The 'AfterAllowTraffic' hook runs after all production traffic is shifted to the new task set, which is the correct moment to trigger a notification task confirming completion.
Step-by-Step Solution
Key Concept
AWS CodeDeploy Lifecycle Hooks for ECS
Alternative Method
Instead of executing tests strictly in AfterAllowTestTraffic, you can also use AfterInstall to perform tests if you do not have a separate test port configured, though AfterAllowTestTraffic is the standard best practice when test traffic routing is configured.
Estimated Time:1m 30s