AWS Certified Developer – Associate (DVA-C02)DeploymentHard
A developer needs to deploy a new version of a critical web application to Amazon EC2 instances using AWS CodeDeploy. Before the new application version starts serving traffic, a set of automated integration tests must be executed to validate its health and functionality. If these tests fail, the deployment must automatically roll back. Which CodeDeploy lifecycle event hook is best suited for running these validation tests immediately after the new application has started?
- AApplicationStop
- BApplicationStart
- CBeforeInstall
- DValidateService
Show answer & explanationAnswer & explanation
Correct answer: D. ValidateService
The 'ValidateService' hook is specifically designed for running tests and validating the health of the newly deployed application version. It executes after the 'ApplicationStart' hook, allowing the application to fully start before validation. If scripts in this hook fail, CodeDeploy can automatically initiate a rollback, ensuring the new version is healthy before it fully takes over.
Why the other options are wrong
- A. ApplicationStop is for stopping the old application, not validating the new one.
- B. ApplicationStart is for starting the application service, not for running validation tests against it.
- C. BeforeInstall runs before any files are copied, which is too early for application validation.
CodeDeploy ValidateService Hook
A CodeDeploy lifecycle event hook that executes after the new application version has started. It is used to run validation tests and health checks, with automatic rollback triggered if the tests fail.
- Runs after the application has started.
- Ideal for integration tests and health checks.
- Supports automatic rollback on script failure.
Memory trick: ValidateService: Test the service, or roll it back!