Create a Database with Amazon RDS and the Mendix Database Connector
Introduction
Amazon Relational Database Service (Amazon RDS) is a collection of managed services that makes it simple to set up, operate, and scale databases in the cloud. You can choose from seven popular engines — Amazon Aurora with MySQL compatibility, Amazon Aurora with PostgreSQL compatibility, MySQL, MariaDB, PostgreSQL, Oracle, and SQL Server — and deploy on-premises with Amazon RDS on AWS Outposts.
This how-to uses PostgreSQL as an example to integrate your Mendix app with Amazon RDS.
Configuring the Mendix Database Connector for Amazon RDS
To configure the Mendix Database Connector for Amazon RDS, follow these steps:
-
Create a database in Amazon RDS by doing the following steps:
-
Select PostgreSQL as the database type.
-
Select the required template.
-
Enter a database instance identifier.
-
Create the Master Username and Master Password. Make sure to store the username and password in a safe location.
-
In the Connectivity section, set Public access to yes.
-
Make sure that Database Authentication is set to Password authentication.
-
-
Optional: If you want to limit access to the database to specific apps, do the following steps:
- After the database is created, access the security group rules.
- Select the first security group.
- Click Edit inbound rules.
- Click Add rule.
- Select PostgreSQL as the database type.
- Select the IP address of your Mendix app as the source. If your app is hosted on Mendix Cloud, see Mendix IP Addresses: Outgoing IP for a list of addresses to safe-list.
- Save the security group rule.
-
Download the Database module and import it into your Mendix app. For more information, see Database.
-
Configure the Database module to connect to AWS RDS by doing the following steps:
-
Use one of the microflow actions provided in the Database connector in a microflow, as described in Database. For example, add the ExecuteStatement action.
-
In the AWS console, in the RDS Database dashboard, find and copy the Connectivity & Security endpoint.
-
In the microflow that you created, in the ExecuteStatement microflow action, configure the jdbcUrl parameter in the following way:
jdbc:postgresql://{endpoint copied from the AWS console}:5432/
-
In the User name and Password parameters, enter the Master Username and Master Password that you configured in AWS RDS in step 1d above, or other credentials with equivalent access rights for AWS RDS.
-
In the Sql parameter, enter your SQL statement. For example, to create a table, you can use the following statement:
CREATE TABLE employee ( emp_id INT PRIMARY KEY, first_name VARCHAR(50) NOT NULL, last_name VARCHAR(50) NOT NULL)
For the PostgreSQL database, you do not need to download the JDBC jar file because the library exists in the userlib folder. -
-
Run your Mendix application and trigger the microflow that you configured.
-
Verify that your Amazon RDS PostgreSQL database contains a new employee table.