DOP-C02 · Question #158
A company's production environment uses an AWS CodeDeploy blue/green deployment to deploy an application. The deployment incudes Amazon EC2 Auto Scaling groups that launch instances that run Amazon…
The correct answer is C. BeforeInstall. Explanation BeforeInstall (Option C) is the correct hook because it runs before the application bundle is installed on the replacement instances, making it the ideal phase to prepare prerequisites like license files that need to be in place before the application starts and…
Question
A company's production environment uses an AWS CodeDeploy blue/green deployment to deploy an application. The deployment incudes Amazon EC2 Auto Scaling groups that launch instances that run Amazon Linux 2. A working appspec.yml file exists in the code repository and contains the following text:
A DevOps engineer needs to ensure that a script downloads and installs a license file onto the instances before the replacement instances start to handle request 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?
Exhibit
Options
- AAfterBlockTraffic
- BBeforeBlockTraffic
- CBeforeInstall
- DDownloadBundle
How the community answered
(26 responses)- A8% (2)
- B4% (1)
- C85% (22)
- D4% (1)
Explanation
Explanation
BeforeInstall (Option C) is the correct hook because it runs before the application bundle is installed on the replacement instances, making it the ideal phase to prepare prerequisites like license files that need to be in place before the application starts and begins handling traffic. This hook executes during the "Install" lifecycle event phase, ensuring the license is available before the app is ever activated.
Why the distractors are wrong:
- AfterBlockTraffic (A) runs on the original (blue) instances after traffic has been blocked from them - this affects the old environment, not the new replacement instances
- BeforeBlockTraffic (B) also runs on the original blue instances before traffic is blocked - again, targeting the wrong instance set
- DownloadBundle (D) is not a valid user-defined hook in CodeDeploy's appspec.yml; it is an internal reserved lifecycle event that cannot be scripted
Memory Tip: Think of the lifecycle as a pipeline on the new (green) instances: BeforeInstall → Install → AfterInstall → ApplicationStart → ValidateService. Anything that must be ready before your app lands on the instance belongs in BeforeInstall - like a "welcome kit" that must be unpacked before guests arrive.
Topics
Community Discussion
No community discussion yet for this question.
