AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)

Configuring Your AWS Elastic Beanstalk Java Environment

To set the system properties that Elastic Beanstalk passes to your server instances, use the AWS Management Console or the AWS Toolkit for Eclipse.

Setting Environment Properties

Environment properties are system properties passed into the Java virtual machine (JVM) at startup to pass database connection strings or other information that you don't want to hard code into your application using the -D flag. Environment properties are specific to your application environment. They are not actual (shell) environment variables. Storing information in environment properties can help increase the portability and scalability of your application. You do not need to recompile your source code when you move between environments. You can acquire environment properties with System.getProperty() (for Tomcat environments) or System.getenv (for Java SE environments).

To set system properties (AWS Management Console)

  1. Open the Elastic Beanstalk console.

  2. Navigate to the management page for your environment.

  3. Choose Configuration.

  4. In the Software Configuration section, choose Edit.

  5. Under Environment Properties, next to JDBC_CONNECTION_STRING, in the Property Value column, type a connection string.

    For example, the following JDBC connection string would connect to a MySQL database instance on port 3306 of localhost, with a username of me and a password of mypassword:


    This will be accessible to your Elastic Beanstalk application as a system property called JDBC_CONNECTION_STRING.

  6. Choose Save.

    Elastic Beanstalk updates your environment. This takes about one minute.


The combined size of all environment properties defined for an environment is limited to 4096 bytes. The format of environment properties is KEY1=VALUE1, KEY2=VALUE2, which means that both the value and key of each variable are included in the total. When a platform has one or more predefined environment properties, such as JDBC_CONNECTION_STRING, those properties are also included in the total.

Accessing Environment Properties

Access the system properties from your code by using System.getProperty() (for Tomcat environments) or System.getenv (for Java SE environments). For example, the following code shows how to read an environment property in a Tomcat servlet:

String jdbcUrl = System.getProperty("JDBC_CONNECTION_STRING");

In a Java SE environment, environment properties are provided as environment variables. If you use the Java SE platform, read environment properties with System.getenv():

String jdbcUrl = System.getenv("JDBC_CONNECTION_STRING");