A developer is configuring a blue/green deployment for a containerized application on Amazon ECS using AWS CodeDeploy. The deployment configuration utilizes an Application Load Balancer with two target groups and a test listener. The developer wants to run automated integration tests against the replacement task set via the test listener to validate the new version of the application before shifting any production traffic.
Which AppSpec lifecycle hook should the developer use to run these integration tests?
- AValidateService
- AfterAllowTestTrafficAnswer
- CBeforeAllowTraffic
- DAfterInstall
Answer
AfterAllowTestTraffic
The correct answer is the hook named AfterAllowTestTraffic. During an ECS blue/green deployment, AWS CodeDeploy executes hooks in a specific order: BeforeInstall, AfterInstall, AfterAllowTestTraffic, BeforeAllowTraffic, and AfterAllowTraffic. The test listener begins routing traffic to the replacement task set just before AfterAllowTestTraffic runs. This is the only point where the application is reachable via the test listener for validation tests before the production listener is updated to point to the replacement task set.
Step-by-Step Solution
Key Concept
AWS CodeDeploy ECS Blue/Green Lifecycle Hooks