A developer is packaging a Node.js web application for deployment to an AWS Elastic Beanstalk environment running on an Amazon Linux platform. The developer needs to run a custom shell script that modifies application files after the application source bundle has been unpacked, but before the application version is started and traffic is routed to it. Which approach should the developer use to ensure the script executes at the correct stage of the deployment lifecycle?
- Place the script inside the `.platform/hooks/predeploy/` directory of the application source bundle and ensure it has executable permissions.Cevap
- BPlace the script inside the `.ebextensions/` folder and execute it using the `commands` key in a configuration file.
- CPlace the script inside the `ebextensions/` folder of the source bundle and configure it to run using the `container_commands` key in a configuration file.
- DPlace the script inside the `.platform/confighooks/predeploy/` directory of the application source bundle.
Cevap
Place the script inside the `.platform/hooks/predeploy/` directory of the application source bundle and ensure it has executable permissions.
The correct option is to place the script inside the `.platform/hooks/predeploy/` directory. On Amazon Linux 2 and Amazon Linux 2023 platforms, Elastic Beanstalk runs scripts placed in this folder after the application source archive is unpacked into the staging folder but before the application process is started. This matches the developer's requirement to modify unpacked files prior to execution.
Adım Adım Çözüm
Anahtar Kavram
AWS Elastic Beanstalk Platform Hooks (.platform/hooks)