AWS Certified Developer – Associate / Question #574 of 557

Question #574

For an in-place deployment using AWS CodeDeploy, what is the correct execution sequence of the lifecycle hooks?

C

ApplicationStart -> BeforeInstall -> AfterInstall -> ApplicationStop

A

BeforeInstall -> ApplicationStop -> AfterInstall -> ApplicationStart

B

ApplicationStop -> AfterInstall -> BeforeInstall -> ApplicationStart

D

ApplicationStop -> BeforeInstall -> AfterInstall -> ApplicationStart

Explanation

In AWS CodeDeploy's in-place deployment, the lifecycle hooks execute in the following order:
1. ApplicationStop: Stops the running application.
2. BeforeInstall: Prepares the environment before installing the new version.
3. AfterInstall: Performs post-installation tasks (e.g., file cleanup).
4. ApplicationStart: Restarts the application with the new version.

Why D is correct: It follows the logical flow: stop the app → prepare → install → start.
Why others are incorrect:
- A: Starts with BeforeInstall, skipping ApplicationStop.
- B: Places AfterInstall before BeforeInstall, violating the sequence.
- C: Starts with ApplicationStart, which is the final step.

Key Points:
- ApplicationStop is always first in in-place deployments.
- BeforeInstall and AfterInstall wrap the installation phase.
- ApplicationStart ensures the updated app is running.

Answer

The correct answer is: D