Soru

Zorluk: ZorAWS Elastic Beanstalk

A developer is packaging a Node.js web application for deployment to an AWS Elastic Beanstalk environment running on an Amazon Linux 20232023 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?

  1. Place the script inside the `.platform/hooks/predeploy/` directory of the application source bundle and ensure it has executable permissions.Cevap
  2. B
    Place the script inside the `.ebextensions/` folder and execute it using the `commands` key in a configuration file.
  3. C
    Place the script inside the `ebextensions/` folder of the source bundle and configure it to run using the `container_commands` key in a configuration file.
  4. D
    Place 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

1
Analyze the target operating system platform and version.
The platform is Amazon Linux 2023, which supports `.platform/` hooks for customizing deployments.
AWS Elastic Beanstalk platforms based on Amazon Linux 2 and Amazon Linux 2023 use the `.platform/` directory structure for lifecycle hooks, replacing the older behavior of running raw scripts directly from `.ebextensions/`.
2
Determine the exact lifecycle stage required for the script execution.
The script must execute after unpacking the source code but before the application runs.
This corresponds to the 'predeploy' phase in Elastic Beanstalk deployment lifecycle stages.
3
Identify the correct directory path and file requirements within the application bundle.
The path is `.platform/hooks/predeploy/`, and files inside must be executable.
Scripts in `.platform/hooks/predeploy/` run automatically at the predeploy phase. Omission of the leading dot in configuration directories or using configuration hooks (`confighooks`) designed for configuration updates will prevent execution during a standard code deployment.

Anahtar Kavram

AWS Elastic Beanstalk Platform Hooks (.platform/hooks)
Bu soruyu puanla