Adding a database to your Elastic Beanstalk environment
Elastic Beanstalk provides integration with Amazon Relational Database Service (Amazon RDS)
A database instance that is part of your environment is tied to the lifecycle of your
environment. You can't remove it from your environment once added.
If you terminate the environment, the database instance is terminated as well. You
can configure Elastic Beanstalk to save a snapshot of the database when you terminate
your environment, and restore a database from a snapshot when you add a DB instance
to an environment. You might incur charges for storing database
snapshots. For more information, see the Backup Storage section of Amazon RDS
Pricing
For a production environment, you can launch a database instance outside of your environment and configure your application to connect to it outside of the functionality provided by Elastic Beanstalk. Using a database instance that is external to your environment requires additional security group and connection string configuration. However, it also lets you connect to the database from multiple environments, use database types not supported with integrated databases, perform blue/green deployments, and tear down your environment without affecting the database instance.
Sections
Adding an Amazon RDS DB instance to your environment
You can add a DB instance to your environment by using the Elastic Beanstalk console.
To add a DB instance to your environment
-
Open the Elastic Beanstalk console
, and in the Regions list, select your AWS Region. -
In the navigation pane, choose Environments, and then choose the name of your environment from the list.
Note If you have many environments, use the search bar to filter the environment list.
-
In the navigation pane, choose Configuration.
-
In the Database configuration category, choose Edit.
-
Choose a DB engine, and enter a user name and password.
-
Choose Apply.
You can configure the following options:
-
Snapshot – Choose an existing database snapshot. Elastic Beanstalk restores the snapshot and adds it to your environment. The default value is None, which lets you configure a new database using the other settings on this page.
-
Engine – Choose a database engine.
-
Engine version – Choose a specific version of the database engine.
-
Instance class – Choose the DB instance class. For information about the DB instance classes, see https://aws.amazon.com/rds/
. -
Storage – Choose the amount of storage to provision for your database. You can increase allocated storage later, but you cannot decrease it. For information about storage allocation, see Features
. -
Username – Enter a user name of your choice using alphanumeric characters.
-
Password – Enter a password of your choice containing 8–16 printable ASCII characters (excluding
/
,\
, and@
). -
Retention – Choose Create snapshot to create a snapshot of the database when you terminate your environment.
-
Availability – Choose High (Multi-AZ) to run a warm backup in a second Availability Zone for high availability.
Elastic Beanstalk creates a master user for the database using the user name and password you provide. To learn more about the master user and its privileges, see Master User Account Privileges.

Adding a DB instance takes about 10 minutes. When the environment update is complete, the DB instance's hostname and other connection information are available to your application through the following environment properties:
Property name | Description | Property value |
---|---|---|
|
The hostname of the DB instance. |
On the Connectivity & security tab on the Amazon RDS console: Endpoint. |
|
The port on which the DB instance accepts connections. The default value varies among DB engines. |
On the Connectivity & security tab on the Amazon RDS console: Port. |
|
The database name, |
On the Configuration tab on the Amazon RDS console: DB Name. |
|
The username that you configured for your database. |
On the Configuration tab on the Amazon RDS console: Master username. |
|
The password that you configured for your database. |
Not available for reference in the Amazon RDS console. |
Connecting to the database
Use the connectivity information to connect to your DB from inside your application through environment variables. For more information about using Amazon RDS with your applications, see the following topics.
-
Java with Tomcat – Connecting to a database (Tomcat platforms)
-
Node.js – Connecting to a database
-
.NET – Connecting to a database
-
Python – Connecting to a database
-
Ruby – Connecting to a database
Configuring an integrated RDS DB Instance using the console
You can view and modify configuration settings for your DB instance in the Database section on the environment's Configuration page in the Elastic Beanstalk console.
To configure your environment's DB instance in the Elastic Beanstalk console
-
Open the Elastic Beanstalk console
, and in the Regions list, select your AWS Region. -
In the navigation pane, choose Environments, and then choose the name of your environment from the list.
Note If you have many environments, use the search bar to filter the environment list.
-
In the navigation pane, choose Configuration.
-
In the Database configuration category, choose Edit.
You can modify the Instance class, Storage, Password, Retention, and Availability settings after database creation. If you change the instance class, Elastic Beanstalk re-provisions the DB instance.
Don't modify settings on the DB instance outside of the functionality provided by Elastic Beanstalk (for example, in the Amazon RDS console). If you do, your Amazon RDS DB configuration might be out of sync with your environment's definition. When you update or restart your environment, the settings specified in the environment override any settings you made outside of Elastic Beanstalk.
If you need to modify settings that Elastic Beanstalk doesn't directly support, use Elastic Beanstalk configuration files.
Configuring an integrated RDS DB Instance using configuration files
You can configure your environment's DB instance using configuration files. Use the options in the aws:rds:dbinstance namespace. The following example modifies the allocated database storage size to 100 GB.
Example .ebextensions/db-instance-options.config
option_settings: aws:rds:dbinstance: DBAllocatedStorage: 100
If you need to configure DB instance properties that Elastic Beanstalk doesn't support,
you can still use a configuration file, and specify your settings using
the resources
key. The following example sets values to the StorageType
and Iops
Amazon RDS properties.
Example .ebextensions/db-instance-properties.config
Resources: AWSEBRDSDatabase: Type: AWS::RDS::DBInstance Properties: StorageType:io1 Iops: 1000