| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
You may want to customize and configure the software that your application depends on. These files could be either dependencies required by the application—for example, additional packages from the yum repository—or they could be configuration files such as a replacement for httpd.conf to override specific settings that are defaulted by AWS Elastic Beanstalk.
This section describes the type of information you can include in a configuration file to customize the software on your EC2 instances running Linux. For general information on customizing and configuring your AWS Elastic Beanstalk environments, see Customizing and Configuring AWS Elastic Beanstalk Environments. For information on customizing software on your EC2 instances running Windows, see Customizing the Software on EC2 Instances Running Windows.
The order in which these are processed are as follows:
Packages
Files
Commands
Services
Container Commands
You can use the packages key to download and install prepackaged applications and components.
packages:<name of package manager>:<package name>:<version>
AWS Elastic Beanstalk currently supports the following package managers: apt, yum, rubygems, python (easy_install), and rpm. Packages are processed in the following order: rpm, yum/apt, and then rubygems and python. There is no ordering between rubygems and python, and packages within each package manager are not guaranteed to be installed in any order.
Within each package manager, each package is specified as a package name and a list of versions. The version can be a string, a list of versions, or an empty string or list. An empty string or list indicates that you want the latest version. For rpm manager, the version is specified as a path to a file on disk or a URL. Relative paths are not supported.
If you specify a version of a package, AWS Elastic Beanstalk attempts to install that version even if a newer version of the package is already installed on the instance. If a newer version is already installed, the deployment fails. Some package managers support multiple versions, but others may not. Please check the documentation for your package manager for more information. If you do not specify a version and a version of the package is already installed, AWS Elastic Beanstalk does not install a new version—it assumes that you want to keep and use the existing version.
The following snippet specifies a version URL for rpm, requests the latest version from yum and apt, and version 0.10.2 of chef from rubygems.
packages:
yum:
libmemcached: []
ruby-devel: []
gcc: []
rpm:
epel: http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
rubygems:
chef: '0.10.2'
apt:
mysql-client: []You can use the sources key to download an archive file and unpack it in a target directory on the EC2 instance. Sources does not automatically build the unpacked sources.
sources:<target directory>:<location of archive file>
Supported formats are tar, tar+gzip, tar+bz2, and zip. You can reference external locations such as Amazon Simple Storage Service (Amazon S3) (e.g., http://s3.amazonaws.com/mybucket/myobject).
The following example downloads a .zip file from an Amazon S3 bucket and unpacks it into /etc/myapp:
sources: /etc/myapp: http://s3.amazonaws.com/mybucket/myobject
You can use the files key to create files on the EC2 instance. The content can be either inline in the configuration file, or the content can be pulled from a URL. The files are written to disk in lexicographic order. You can reference external locations such as Amazon S3 (e.g., http://s3.amazonaws.com/mybucket/myobject). The following table lists the supported keys.
files: "<target file location on disk>": mode: "<six-digit octal value>" owner:<name of owning user for file>group:<name of owning group for file>source:<URL>authentication:<authentication name>: "<target file location on disk>": mode: "<six-digit octal value>" owner:<name of owning user for file>group:<name of owning group for file>content: |this is my contentencoding:encoding formatauthentication:<authentication name>:
| Key | Description |
|---|---|
|
|
A string. |
|
|
A URL to load the file from. This option cannot be specified with the content key. |
|
|
The encoding format. Only used if the content is a string. Encoding is not applied if you are using a source. Valid values: |
|
|
The name of the owning group for this file. |
|
|
The name of the owning user for this file. |
|
|
A six-digit octal value representing the mode for this file (e.g, "000444"). The first three digits are used for symlinks and the last three digits are used for setting permissions. |
|
|
The name of an authentication method to use. This overrides any default authentication. |
files:
“/home/ec2-user/myfile” :
mode: "000777"
owner: ec2-user
group: ec2-user
source: http://foo.bar/myfile
“/home/ec2-user/myfile2” :
mode: “000777”
owner: ec2-user
group: ec2-user
content: |
# this is my file
# with contentExample using a symlink. This creates a link /tmp/myfile2.txt that points at the existing file /tmp/myfile1.txt.
files:
“/tmp/myfile2.txt” :
mode: "120400"
content: “/tmp/myfile1.txt”You can use the users key to create Linux/UNIX users on the EC2 instance.
users:<name of user>: groups: -<name of group>uid: "<id of the user>" homeDir: “<user's home directory>"
| Key | Description |
|---|---|
|
|
A user ID. The creation process fails if the user name exists with a different user ID. If the user ID is already assigned to an existing user, the operating system may reject the creation request. |
|
|
A list of group names. The user is added to each group in the list. |
|
|
The user's home directory. |
Users are created as noninteractive system users with a shell of /sbin/nologin. This is by design and cannot be modified.
users:
myuser:
groups:
- group1
- group2
uid: "50"
homeDir: “/tmp”You can use the groups key to create Linux/UNIX groups and to assign group IDs. To create a group, add a new key-value pair that maps a new group name to an optional group ID. The groups key can contain one or more group names. The following table lists the available keys.
groups:<name of group>:<name of group>: gid: "<group id>"
| Key | Description |
|---|---|
|
|
A group ID number. If a group ID is specified, and the group already exists by name, the group creation will fail. If another group has the specified group ID, the operating system may reject the group creation. |
The following snippet specifies a group named groupOne without assigning a group ID and a group named groupTwo that specified a group ID value of 45.
groups:
groupOne:
groupTwo:
gid: "45"You can use the commands key to execute commands on the EC2 instance. The commands are processed in alphabetical order by name, and they run before the application and web server are set up and the application version file is extracted.
commands:
test_command:
command: <command to run>
cwd: <working directory>
env:
<variable name>: <variable value>
ignoreErrors: true| Key | Description |
|---|---|
|
|
Required. Either an array or a string specifying the command to run. If you use an array, you do not need to escape space characters or enclose command parameters in quotes. |
|
|
Optional. Sets environment variables for the command. This property overwrites, rather than appends, the existing environment. |
|
|
Optional. The working directory. By default, AWS Elastic Beanstalk attempts to find the directory location of your project. If not found, then "/" is used. |
|
|
Optional. A command that must return the value |
|
|
Optional. A boolean value that determines if other commands should run if the
command contained in the |
The following example snippet runs a python script.
commands:
test:
command: myscript.py
cwd: /home/ec2-user
env:
myvarname: myvarvalueYou can use the container_commands key to execute commands for your container.
The commands in container_commands are processed in alphabetical order by name. They run after the
application and web server have been set up and the application version file has
been extracted, but before the application version is deployed. They also have
access to environment variables such as your AWS security credentials. Additionally,
you can use leader_only. One instance is chosen to be the
leader in an Auto Scaling group. If the leader_only value is
set to true, the command runs only on the instance that is marked as the
leader.
container_commands:<name of container_command>: command:<command to run>leader_only: true<name of container_command>: command:<command to run>
| Key | Description |
|---|---|
|
|
Required. Either an array or a string specifying the command to run. If you use an array, you do not need to escape space characters or enclose command parameters in quotes. |
|
|
Optional. Sets environment variables for the command. This property overwrites, rather than appends, the existing environment. |
|
|
Optional. The working directory. By default, this is the directory of the unzipped application. |
|
|
Optional. Sets an instance in the Auto Scaling group to be the leader. If the
|
|
|
Optional. A command that must return the value |
|
|
Optional. A boolean value that determines if other commands should run if the
command contained in the command key fails (returns a
nonzero value). Set this value to |
The following is an example snippet.
container_commands:
collectstatic:
command: "django-admin.py collectstatic --noinput"
01syncdb:
command: "django-admin.py syncdb --noinput"
leader_only: true
02migrate:
command: "django-admin.py migrate"
leader_only: true
99customize:
command: "scripts/customize.sh"You can use the services key to define
which services should be started or stopped when the instance is launched. The
services key also allows you to specify dependencies on sources, packages, and
files so that if a restart is needed due to files being installed, AWS Elastic Beanstalk
takes care of the service restart.
services:
sysvinit:
<name of service>:
enabled: true
ensureRunning: true
files: "<file name>"
sources: "<directory>"
packages:
<name of package manager>:
<package name>: <version>
commands:
<name of command>:The following table lists the supported keys.
| Key | Description |
|---|---|
|
|
Set to Set to Omit this key to make no changes to the service state. |
|
|
Set to Set to Omit this key to make no changes to this property. |
|
|
A list of files. If AWS Elastic Beanstalk changes one directly via the files block, the service is restarted. |
|
|
A list of directories. If AWS Elastic Beanstalk expands an archive into one of these directories, the service is restarted. |
|
|
A map of the package manager to a list of package names. If AWS Elastic Beanstalk installs or updates one of these packages, the service is restarted. |
|
|
A list of command names. If AWS Elastic Beanstalk runs the specified command, the service is restarted. |
The following is an example snippet:
services:
sysvinit:
myservice:
enabled: true
ensureRunning: trueOption_settings enables you to modify the Elastic Beanstalk
configuration and define variables that can be retrieved from your application using
environment variables. The following table displays the namespaces that are
supported for each container type. Some namespaces allow you to extend the number of
parameters, and specify the parameter names.
option_settings: - namespace:<namespace>option_name:<option name>value:<option value>- option_name:<option name>value:<option value>
| Container | Namespace | Extend |
|---|---|---|
| Java |
|
Yes Yes |
| Node.js |
|
Yes No Yes |
| PHP |
|
Yes No |
| Python |
|
Yes No Yes |
| Ruby |
|
Yes |
Note
If you do not specify a namespace, the default used is
aws:elasticbeanstalk:application:environment.
The folllowing is an example snippet.
option_settings:
- namespace: aws:elasticbeanstalk:container:tomcat:jvmoptions
option_name: Xmx
value: 256m
- option_name: myparam1
value: somevalue