How do I customize my Elastic Beanstalk environment using .ebextensions?
Last updated: 2019-05-20
How do I customize my AWS Elastic Beanstalk environment using .ebextensions to create files, install packages, and run commands on my Amazon Elastic Compute Cloud (Amazon EC2) instances?
Configure your Amazon EC2 instances in an Elastic Beanstalk environment by using Elastic Beanstalk configuration files (.ebextensions).
Configuration changes made to your Elastic Beanstalk environment won't persist if you use the following configuration methods:
- Configuring an Elastic Beanstalk resource directly from the console of a specific AWS service.
- Installing a package, creating a file, or running a command directly from your Amazon EC2 instance.
Note: If you receive errors when running AWS Command Line Interface (AWS CLI) commands, make sure that you’re using the most recent AWS CLI version.
Set up your .ebextensions directory
1. In the root of your application bundle, create a hidden directory named .ebextensions.
2. Store your configuration file in the .ebextensions directory.
Your application source bundle should look similar to the following example:
~/workspace/my-application/ |-- .ebextensions | |-- 01-server-configuration.config | `-- 02-asg-healthcheck.config |-- index.php `-- styles.css
Customize your Elastic Beanstalk environment
To customize your environment, consider the following:
- Use the option_settings key to modify the environment configuration. You can choose from general options for all environments and platform-specific options.
Note: Recommended values are applied when you create or update an environment on the Elastic Beanstalk API by a client. For example, the client could be the AWS Management Console, Elastic Beanstalk Command Line Interface (EB CLI), AWS CLI, or SDKs. Recommended values are directly set at the API level and have the highest precedence. The configuration setting applied at the API level can't be changed using option_settings, as the API has the highest precedence.
- Precedence rules can result in your option_settings modifications not being applied to the environment configuration. To remove the configurations directly applied during environment creation or make the update on the Elastic Beanstalk API, use the update-environment command with the --options-to-remove flag.
- If there are no option settings for your desired resource configuration, use the Resources key to customize the 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. All AWS CloudFormation resource types are supported. 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 the AWS GitHub repository.
Apply your custom settings to your application
1. Create an application source bundle that includes your configuration files.
Note: Folders starting 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.
Did this article help?
Do you need billing or technical support?