Templates
Strapi Serverless

Access the RDS database

7min

The Strapi app and the RDS database reside in a VPC private network and all traffic from the outside is blocked by default. This means that you cannot directly access the service or the database from the Internet.

However, if you need to access the database from your local machine there is a way to do so by following the instructions below:

1. Create EC2 key pair

To create a new EC2 key-pair, go to AWS console, choose EC2 service and from the left panel, choose Key Pairs, and click Create key pair in the top right. The name you choose here is the one used to configure the VPC resource in the Microtica Developer Portal.

Create EC2 key pair
Create EC2 key pair


EC2 key-pair

You will need to create an EC2 key-pair from the AWS console. We don’t create it automatically due to security reasons. This key should always be in your possession and kept in a secure place. It will allow you to access your EC2 instances through SSH.

2. Allow SSH access from your public IP address

In the AWS console, go to EC2 service, select the VPC-nat instance. In the Security tab click on the security group.

Allow SSH access from your public IP address
Allow SSH access from your public IP address


Edit the inbound rules by whitelisting your public IP address for port 22 (SSH port). Save the changes.

Whitelist your public IP address
Whitelist your public IP address


3. Configure the VPC resource in the Microtica Developer Portal

The next thing you need to do is to add the name of the key pair you’ve just created by updating the configuration of the VPC resource in the Strapi environment. Go to your Strapi environment, under Resources select VPC resource > Resource Settings. Enter the keyName you created previously and click on Save and Deploy button.

Configure the VPC resource in Microtica
Configure the VPC resource in Microtica


4. Connect with the database over SSH

Now you have everything ready to establish a connection with the database. To get the necessary information, follow the steps below:

  • Select the VPC resource and in Resource Outputs you can get the NAT instance IP and use it as an SSH hostname. Set SSH username to ec2-user.
Connect with the database over SSH
Connect with the database over SSH




  • Select the Strapi resource and in Resource Outputs you can get the database endpointport, and username. The database password is securely stored in AWS Secret Manager specified in the DatabaseSecret output parameter.
Resource outputs in Microtica
Resource outputs in Microtica

  • And last, use your preferred client (e.g. pgAdmin, MySQLWorkbench) to connect with the Strapi database.

If you prefer using CLI to access the database, you should first establish a tunnel to your database and then connect with the database with the following commands:

PostgreSQL