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.
Resolution
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshooting errors for the AWS CLI. Also, make sure that you're using the most recent AWS CLI version.
Set up your .ebextensions directory
Complete the following steps:
- In the root of your application bundle, create a hidden directory that you name .ebextensions.
- Store your configuration file in the .ebextensions directory. Your application source bundle looks 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 modify your environment configuration, use the option_settings key. 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 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 UpdateEnvironment Elastic Beanstalk API.
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: Elastic Beanstalk adds the resources that you define in the configuration files 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.
Configuration files must have the .config file extension and must use either the YAML or JSON format.
Use keys to customize software on Linux or Windows servers and use each key only once in each configuration file.
When you deploy your application to Elastic Beanstalk, use various sections in your .ebextensions configuration files to customize the EC2 instances. For configuration file samples, see elastic-beanstalk-samples on the GitHub website.
Apply your custom settings to your application
Complete the following steps:
- Create an application source bundle that includes your configuration files.
Note: File browsers might hide folders that start with a period, such as .ebextensions. To keep these folders visible, include the .ebextensions folder in the root of your application bundle when you create your application source bundle.
- Deploy your updated Elastic Beanstalk application.
Related information
Option settings