Question

Difficulty: Very hardAWS Elastic Beanstalk

A developer is migrating a Node.js web application to an AWS Elastic Beanstalk environment running on an Amazon Linux 2023 platform. The application requires two specific configurations:
1. It must execute a custom shell script named `configure-auth.sh` to download and configure an SSL certificate *after* the application files are extracted and staged on the host, but *before* the application process is launched.
2. It must configure a system environment variable named `DB_MAX_CONN` with a value of `100` across all instances.

Which two actions should the developer take to successfully deploy these customizations? (Select TWO.)

  1. Place the script `configure-auth.sh` in the `.platform/hooks/predeploy/` directory of the application source bundle and ensure it has execute permissions.Answer
  2. Create a configuration file named `db.config` containing the option settings for the `aws:elasticbeanstalk:application:environment` namespace and place it in the `.ebextensions/` directory at the root of the source bundle.Answer
  3. C
    Create a configuration file named `db.config` containing the environment settings and place it in a folder named `ebextensions/` (without the leading dot) at the root of the source bundle.
  4. D
    Place the script `configure-auth.sh` in the `.ebextensions/hooks/predeploy/` directory of the application source bundle.
  5. E
    Define the `DB_MAX_CONN` environment variable in the application's package manager configuration (such as `package.json` for Node.js) under a custom Elastic Beanstalk section.

Answer

The developer must place the script in the `.platform/hooks/predeploy/` directory with execution permissions, and place the environment variable configuration file in the `.ebextensions/` directory.
The correct options state that the hook script must be located in `.platform/hooks/predeploy/` with execution permissions, and the configuration file for the environment variable must be located in `.ebextensions/` at the root of the source bundle. Under Amazon Linux 2 and Amazon Linux 2023 platforms, Elastic Beanstalk uses `.platform/hooks/predeploy/` to run custom scripts after the source bundle has been extracted and staged but before the application process is executed. The `.ebextensions/` directory containing configuration files is the standard mechanism to set environment variables through the `aws:elasticbeanstalk:application:environment` namespace.

Step-by-Step Solution

1
Determine the platform hook structure for Amazon Linux 2023.
Identify that script files must be placed in the `.platform/hooks/` subdirectories to execute during lifecycle stages (specifically `predeploy` for actions after staging but before running).
Elastic Beanstalk's Amazon Linux 2 and Amazon Linux 2023 platforms use `.platform/hooks/` instead of older platform hooks methods.
2
Ensure script execution permission.
Add execution permission (`chmod +x`) to `configure-auth.sh` before archiving the bundle.
Scripts in platform hooks must be executable to run successfully.
3
Determine environment variable configuration location.
Identify that the standard configuration directory is `.ebextensions/` (with a leading dot).
Elastic Beanstalk reads configuration files matching `*.config` in the `.ebextensions/` directory at the root of the source bundle.
4
Specify namespace and variable value.
Use `aws:elasticbeanstalk:application:environment` configuration namespace to set `DB_MAX_CONN` to `100`.
This is the correct namespace to inject system environment variables into the application runtime.

Key Concept

AWS Elastic Beanstalk Amazon Linux 2/2023 Platform Customization via .platform and .ebextensions
Estimated Time:3m 0s
Rate this question