Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect AWS aurora (posgresSQL) using prisma

I am working with nest.js to build an API . I created a serverless RDS aurora for postgresSQl to use it as a database.

This is my aurora(postgresSQL) database instance (Connectivity and Security) enter image description here

  • This is my database Configuration enter image description here

  • This is my security group detail enter image description here

Then I try connect by using endpoint,database,user etc, by using prisma in nest.js :

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = "postgresql://postgres:password@med.cluster-cnonikf1pbgi.ap-southeast-1.rds.amazonaws.com:5432/Medi?schema=public&ssl=true"
}

But when I run this command:

npx prisma migrate dev --name init

I got an error like this:

Error: P1001: Can't reach database server at `med.cluster-cnonikf1pbgi.ap-southeast-1.rds.amazonaws.com`:`5432`

Please make sure your database server is running at `med.cluster-cnonikf1pbgi.ap-southeast-1.rds.amazonaws.com`:`5432`.
like image 608
Navin Seab Avatar asked Oct 19 '25 05:10

Navin Seab


1 Answers

I was able to connect directly to my Aurora Cluster without the need of a special gateway or ec2 instance. This worked for me:

  1. Make sure you have "Public access" set to "Publicly accessible". You should see this option when created the db but you can also modify it once the db has already been created by going to RDS -> Databases -> Select a db instance and not the cluster (the cluster does not seem to provide this option) -> Click "Modify" button in top right -> scroll down to the "Connectivity" Section -> Expand it and you'll see the option to change this setting.

  2. Ensure the VPC "security group" that you have assigned to your DB grants external access to your DB. The same "Connectivity" section from step 1 also shows the VPC security group that your DB is using. Take note of it's name. You can view the details of your security group by going to the "VPC" service config page: VPC -> security groups -> click on your security group -> examine the inbound rules -> if needed create a new rule by click in "edit inbound rules" -> add rule. If you want to give access to just your IP you can choose "My IP", which will prefill your current IP address.

Some resources I found helpful:

Connecting from internet into VPC

Trouble Shooting Connectivity

like image 123
GxXc Avatar answered Oct 21 '25 20:10

GxXc