Q58 — AWS DOP-C02 Ch.2
Question 58 of 100 | ← Chapter 2
A company uses AWS CodeDeploy blue/green deployments to deploy an application. The deployment includes Amazon EC2 Auto Scaling groups launching instances running Amazon Linux 2. A valid appspec.yml file exists in the code repository containing the following text: A DevOps engineer must ensure that a script downloads and installs a license file on the instance before replacement instances begin handling traffic. The DevOps engineer adds a hooks section to the appspec.yml file. Which hook should the DevOps engineer use to run the script that downloads and installs the license file?
- A. AfterTrafficHook
- B. BeforeTrafficHook
- C. BeforeInstall ✓
- D. DownloadBundle
Correct Answer: C. BeforeInstall
Explanation
AWS CodeDeploy blue/green deployment lifecycle hooks determine script execution timing. Per AWS documentation, the `BeforeInstall` hook runs after the application revision package is installed but before the application starts. Installing a license file is a pre-application-start dependency setup task. Option C corresponds precisely to this stage, ensuring licenses are installed before traffic routing begins. Options A and B relate to traffic routing phases, and Option D is an automatic system-managed phase—not suitable for this use case. Source: AWS CodeDeploy AppSpec File Reference.