Sharing databases between applications

Overview

It is possible for two Maestro applications to share a single database server. However it requires some manual configuration to do properly.

Configuring for a shared database

Firstly, you need to open your firewall on the first stack to allow your second applications web servers to access the database.

You will then reference the database credentials from your first application in the configuration file of your second application.

Note

You need admin access to both of the applications in order for this to work correctly.

You can reference the environment variables for these credentials on your first application using this format:

{{ STACK[APP_UID].ENV_VAR }}

Your application UID is available via the Dashboard on the Settings & Information page under the Information tab.

For example, your environment variables would be set like this:

MYSQL_ADDRESS={{ STACK[xyz].MYSQL_ADDRESS_INT }}
MYSQL_DATABASE={{ STACK[xyz].MYSQL_DATABASE }}

Database credentials

Database credentials such as username and password are not available for cross-stack referencing for security reasons. Instead, copy and paste them across as environment variables. Your database configuration file would look something like this:

host: \<%= ENV['MYSQL_ADDRESS'] %\>
username: \<%= ENV['MYSQL_USERNAME'] %\>
password: \<%= ENV['MYSQL_PASSWORD'] %\>
database: \<%= ENV['MYSQL_DATABASE'] %\>