AWS Certified Developer – Associate (DVA-C02)DeploymentMedium

A company is using AWS CodePipeline to automate its software release process. They have a stage that deploys an application to Amazon EC2 instances using AWS CodeDeploy. After deployment, they need to run a series of integration tests. Where should the commands for these integration tests be specified within the CodeDeploy deployment lifecycle?

  1. AAfterAllowTraffic hook in the AppSpec file
  2. BApplicationStop hook in the AppSpec file
  3. CValidateService hook in the AppSpec file
  4. DBeforeInstall hook in the AppSpec file
Show answer & explanation

Correct answer: C. ValidateService hook in the AppSpec file

The ValidateService hook is specifically designed for running tests and validating the health of the newly deployed application after it has started and is serving traffic. This is the ideal place for integration tests.

Why the other options are wrong

  • A. AfterAllowTraffic runs after traffic is shifted to the new deployment, but ValidateService is the designated hook for service validation/testing.
  • B. ApplicationStop runs before the application stops, not suitable for testing a *running* new deployment.
  • D. BeforeInstall runs before the application revision is installed, too early for integration tests.

CodeDeploy AppSpec Hooks

AppSpec file hooks define scripts to run at various stages of the CodeDeploy deployment lifecycle on an EC2/on-premises instance. These hooks allow for custom actions like installing dependencies, starting services, and running tests.

  • Defines deployment actions.
  • Specific hooks for different lifecycle events.
  • Scripts are executed on target instances.
  • Crucial for automation and validation.

Memory trick: AppSpec hooks orchestrate your deployment's every move, validate to prove.

More Deployment questions