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

Configuring Databases with Elastic Beanstalk

Elastic Beanstalk provides integration with Amazon RDS to help you add a database instance to your Elastic Beanstalk environment. You can use Elastic Beanstalk to add a MySQL, PostgreSQL, Oracle, or SQL Server database to your environment during or after environment creation. When you add a database instance to your environment, Elastic Beanstalk provides connection information to your application by setting environment properties for the database hostname, port, username, password, and database name.

A database instance that is part of your environment is tied to the lifecycle of your environment. If you terminate the environment, the database instance is terminated as well. An integrated database instance also cannot be removed from your environment once added.

For a production environment, you may want to 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 external to your environment requires additional security group and connection string configuration, but 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.

Configuring an Integrated RDS DB Instance

If you have a database associated with your environment, you can view the configuration settings by viewing the settings in the Data Tier section on the environment's Configuration page in the environment management console.

If you don't have an Amazon RDS database associated with your environment, you can associate one by clicking create a new RDS database on the Configuration page in the environment management console.

To create an Amazon RDS database and associate it with your existing environment

  1. On the Configuration page, under Data Tier, click create a new RDS database.

  2. Configure the following settings for your database:

    • (Optional) For Snapshot, select whether to create an Amazon RDS DB from an existing snapshot.

    • (Optional) For DB engine, select a database engine.

    • (Optional) For Instance Class, select a database instance class. For information about the DB instance classes, go to http://aws.amazon.com/rds/.

    • For Allocated Storage, type the space needed for your database. You can allocate between 5 GB and 1024 GB. You cannot update the allocated storage for a database to a lower amount after you set it. In some cases, allocating a larger amount of storage for your DB instance than the size of your database can improve IO performance. For information about storage allocation, go to Features.

    • For Master Username, type a name using alphanumeric characters that you will use to log in to your DB instance with all database privileges.

    • For Master Password, type a password containing 8 to 16 printable ASCII characters (excluding /, \, and @).

    • For Deletion Policy, select Create snapshot to create a snapshot that you can use later to create another Amazon RDS database. Select Delete to delete the DB instance when you terminate the environment. If you select Delete, you lose your DB instance and all the data in it when you terminate the Elastic Beanstalk instance associated with it. By default, Elastic Beanstalk creates and saves a snapshot. You can use a snapshot to restore data to use in a new environment, but cannot otherwise recover lost data.

      Note

      You may incur charges for storing database snapshots. For more information, see the "Backup Storage" section of Amazon RDS Pricing.

    • For Availability, select one of the following:

      • To configure your database in one Availability Zone, select Single Availability Zone. A database instance launched in one Availability Zone does not have protection from the failure of a single location.

      • To configure your database across multiple availability zones, select Multiple Availability Zones. Running your database instance in multiple Availability Zones helps safeguard your data in the unlikely event of a database instance component failure or service health disruption in one Availability Zone.

  3. Click Save.

    Elastic Beanstalk updates the environment and creates the Amazon RDS database. After the update is complete, you can view the databases by going to the Configuration page.

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.

You can use the Elastic Beanstalk Management Console to edit some settings for the Amazon RDS database associated with your environment.

To edit the Amazon RDS database instance associated with your environment

  1. On the Configuration page, under Data Tier, click Edit for the RDS settings.

  2. Update the configuration for any of the following Amazon RDS database settings:

    • For Master Password, type a password containing 8 to 16 printable ASCII characters (excluding /, \, and @).

    • For Allocated Storage, type the space needed for your database. You can allocate between 5 GB and 1024 GB. You cannot update the allocated storage for a database to a lower amount after you set it. In some cases, allocating a larger amount of storage for your DB instance than the size of your database can improve IO performance. For information about storage allocation, go to Features.

    • (Optional) For Instance Class, select a database instance class. For information about the DB instance classes, go to http://aws.amazon.com/rds/.

    • For Deletion Policy, select Create snapshot to create a snapshot that you can use later to create another Amazon RDS database. Select Delete to delete the DB instance when you terminate the environment. If you select Delete, you lose your DB instance and all the data in it when you terminate the Elastic Beanstalk instance associated with it. By default, Elastic Beanstalk creates and saves a snapshot. You can use a snapshot to restore data to use in a new environment, but cannot otherwise recover lost data.

      Note

      You may incur charges for storing database snapshots. For more information, see the "Backup Storage" section of Amazon RDS Pricing.

    • For Availability, select one of the following:

      • To configure your database in one Availability Zone, select Single Availability Zone. A database instance launched in one Availability Zone does not have protection from the failure of a single location.

      • To configure your database across multiple availability zones, select Multiple Availability Zones. Running your database instance in multiple Availability Zones helps safeguard your data in the unlikely event of a database instance component failure or service health disruption in one Availability Zone.

  3. Click Save.

    Elastic Beanstalk updates the environment, replacing the Amazon RDS database if you changed the database instance class.