How do I use .ebextensions to customize my Elastic Beanstalk environment?

3 minute read

I want to customize my AWS Elastic Beanstalk environment to create files, install packages, and run commands on Amazon Elastic Compute Cloud (Amazon EC2) instances.


Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.

Set up your .ebextensions directory

To set up your .ebextensions directory, complete the following steps:

  1. In the root of your application bundle, create a hidden directory that you name .ebextensions.
  2. Store your configuration file in the .ebextensions directory. Your application source bundle looks similar to the following example:
    |-- .ebextensions
    |   |-- 01-server-configuration.config
    |   `-- 02-asg-healthcheck.config
    |-- index.php
    `-- styles.css

Customize your Elastic Beanstalk environment

To customize your environment, review the following these best practices:

  • Use the option_settings key to modify the environment configuration. You can choose from general options for all environments and platform specific options.
    Note: When you create or update an environment on the Elastic Beanstalk API, the client applies recommended values. Recommended values are directly set at the API level and have the highest precedence. You can't use the option_settings to change the configuration setting.
  • Precedence rules can stop the application of your option_settings modifications to the environment configuration. To remove the configurations directly applied during environment creation, use the update-environment command with the --options-to-remove flag. You can also use the Elastic Beanstalk API to run the command and make the update
  • If there are no option settings for your desired resource configuration, then use the Resources key to customize resources in your Elastic Beanstalk environment.
    Note: Resources defined in configuration files are added to the AWS CloudFormation template that's used to launch your environment. The CloudFormation template supports all CloudFormation resource types. For more information on logical resource names, see Modifying the resources that Elastic Beanstalk creates for your environment.
  • Use keys to customize software on Linux or Windows servers.
  • For configuration file samples, see elastic-beanstalk-samples on the GitHub website.

Apply your custom settings to your application

To apply your custom settings to your application, complete the following steps:

  1. Create an application source bundle that includes your configuration files.
    Note: Folders that start with a period, such as .ebextensions, can be hidden by file browsers. To keep these folders visible, include the .ebextensions folder in the root of your application bundle when you create your application source bundle.
  2. Deploy your updated Elastic Beanstalk application.

Related information

Option settings

AWS OFFICIALUpdated a month ago