AWS Certified Developer – Associate (DVA-C02)DeploymentMedium

A company is using AWS CodeDeploy to deploy a new version of its web application to an Auto Scaling group of Amazon EC2 instances. During the deployment, they need to execute a custom script on each instance to update local configuration files immediately after the new application revision is downloaded, but before the application traffic is rerouted. Which CodeDeploy lifecycle event hook should be used for this purpose?

  1. ABeforeInstall
  2. BAfterAllowTraffic
  3. CApplicationStart
  4. DAfterInstall
Show answer & explanation

Correct answer: D. AfterInstall

The AfterInstall lifecycle event hook is executed after the application revision is successfully downloaded and installed on the instance, but before the application itself starts or traffic is rerouted. This makes it the ideal place to run custom scripts for configuration updates that depend on the newly installed files.

Why the other options are wrong

  • A. This hook runs before the application revision files are copied to the instance. The configuration update needs to happen after the new files are present.
  • B. This hook runs after traffic has been shifted to the new deployment, which is too late for pre-traffic configuration updates.
  • C. This hook runs after AfterInstall and before ValidateService, when the application service is started. The configuration needs to be updated before this.

CodeDeploy AfterInstall Hook

A CodeDeploy lifecycle event hook that executes custom scripts immediately after the application revision files are copied to the instance.

  • Runs after application files are installed.
  • Runs before the application starts or traffic shifts.
  • Ideal for post-installation configuration or setup tasks.

Memory trick: After install, configure all, before traffic's call.

More Deployment questions