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

3 minutos de lectura
0

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

Resolution

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 that you name .ebextensions.

  2. Store your configuration file in the .ebextensions directory.

    Your application source bundle looks similar to this 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 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 AWS GitHub repository website.

Apply your custom settings to your application

  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

OFICIAL DE AWS
OFICIAL DE AWSActualizada hace 7 meses