AWS Certified Developer – Associate (DVA-C02)DeploymentHard

A development team is deploying a new version of a critical web application to Amazon EC2 instances using AWS CodeDeploy. They need to ensure that the application is fully functional and responsive before any traffic is routed to the newly deployed instances. If the application does not pass these health checks, the deployment should automatically roll back. Which CodeDeploy lifecycle event hook and associated action should be used to achieve this?

  1. AAfterAllowTraffic hook to perform post-deployment monitoring.
  2. BBeforeInstall hook to run basic unit tests.
  3. CValidateService hook to run comprehensive health checks and trigger rollback on failure.
  4. DApplicationStart hook to start the application service.
Show answer & explanation

Correct answer: C. ValidateService hook to run comprehensive health checks and trigger rollback on failure.

The ValidateService lifecycle event hook is specifically designed for running comprehensive health checks and validation tests after the application has started on the new deployment, but before any traffic is directed to it. If the scripts executed during this hook fail, CodeDeploy can be configured to automatically roll back the deployment, ensuring that only healthy instances receive traffic.

Why the other options are wrong

  • A. AfterAllowTraffic runs after traffic has already been routed to the new instances, which is too late to prevent unhealthy instances from receiving traffic and triggering an automatic rollback before traffic shift.
  • B. BeforeInstall runs before the new application is even installed, so it can't validate the running application's functionality.
  • D. ApplicationStart simply starts the application service; it doesn't perform health checks or trigger rollbacks based on application health.

CodeDeploy ValidateService Hook

A CodeDeploy lifecycle event hook that executes scripts to perform health checks and validation tests on a newly deployed application *before* it starts receiving production traffic. Failures can trigger automatic rollbacks.

  • Runs after application starts, before traffic shift.
  • Ideal for comprehensive health and integration tests.
  • Failure can initiate automatic rollback.
  • Ensures only healthy deployments receive traffic.

Memory trick: Validate service, before traffic's surge, for a seamless merge.

More Deployment questions