Question

Difficulty: MediumAWS Elastic Beanstalk

A developer is configuring a web application for deployment on AWS Elastic Beanstalk. The application requires a runtime environment variable named 'DATABASE_URL'. Additionally, the application requires an Amazon S3 bucket for storing user uploads, and this bucket's lifecycle must be tied directly to the Elastic Beanstalk environment. Which two configuration steps should the developer perform to satisfy these requirements? (Select TWO.)

  1. Place a '.config' configuration file inside a directory named '.ebextensions' at the root of the application source bundle, defining the environment variable under the 'aws:elasticbeanstalk:application:environment' namespace.Answer
  2. Place a '.config' configuration file inside a directory named '.ebextensions' at the root of the application source bundle, defining the S3 bucket under the 'Resources' block using CloudFormation syntax.Answer
  3. C
    Store a configuration file within a directory named 'ebextensions' (without a prefix dot) located at the root of the application package to configure the settings and resources.
  4. D
    Add an 'appspec.yml' file to the root of the project source, specifying the database connection string and S3 bucket details in the hooks section.
  5. E
    Configure a 'buildspec.yml' file at the root level to provision the S3 bucket and inject the database environment variable during the deployment phases.

Answer

To satisfy the requirements, the developer must place a '.config' file within a '.ebextensions' directory at the root of the application source bundle. In this file, the 'DATABASE_URL' environment variable should be defined under the 'aws:elasticbeanstalk:application:environment' namespace, and the Amazon S3 bucket should be defined as a resource under the 'Resources' block using standard CloudFormation syntax.
The correct options describe placing '.config' files in a folder named '.ebextensions' at the root of the source bundle. To configure environment variables, the developer uses the 'aws:elasticbeanstalk:application:environment' namespace inside the configuration file. To provision custom resources like an S3 bucket that share the environment's lifecycle, the developer includes standard CloudFormation resource definitions under the 'Resources' key in the configuration files.

Step-by-Step Solution

1
Identify the directory location and file extension for Elastic Beanstalk configuration files.
The files must have a '.config' extension and must be placed in a folder named '.ebextensions' (with a leading period) at the root of the source bundle.
Elastic Beanstalk only processes configuration files that reside in this specific directory path.
2
Determine the namespace for setting environment properties/variables.
The correct namespace is 'aws:elasticbeanstalk:application:environment' within the 'option_settings' block of the configuration file.
This namespace informs Elastic Beanstalk to inject the properties as environment variables accessible by the application code at runtime.
3
Define the custom resource with a lifecycle tied to the Elastic Beanstalk environment.
Add a 'Resources' block containing the Amazon S3 bucket definition using AWS CloudFormation syntax in one of the '.config' files.
Elastic Beanstalk parses the 'Resources' section of '.config' files and adds those resources directly to the environment's underlying CloudFormation stack, managing their lifecycle together.

Key Concept

AWS Elastic Beanstalk configuration files ('.ebextensions') and resource provisioning
Estimated Time:2m 0s
Rate this question