A developer needs to run a database migration script on Amazon EC2 instances before the new application files are copied during an AWS CodeDeploy deployment. Which configuration file and lifecycle hook should the developer use to execute this script?
- AA buildspec.yml file in the root directory, running the script in the pre_build phase
- BAn appspec.yml file in the root directory, running the script in the BeforeAllowTraffic hook
- An appspec.yml file in the root directory, running the script in the BeforeInstall hookCevap
- DA configuration file in the .ebextensions directory, running the script in container_commands
Cevap
An appspec.yml file in the root directory, running the script in the BeforeInstall hook
AWS CodeDeploy manages EC2/On-Premises deployments using the appspec.yml file located in the root of the source directory. In this file, the developer can define hooks to run scripts at specific phases. The BeforeInstall hook is the appropriate hook to execute scripts (such as database migrations or clearing temp folders) before the actual application files are copied to the instance during the installation phase.
Adım Adım Çözüm
Anahtar Kavram
AWS CodeDeploy AppSpec lifecycle hooks for EC2 deployments