Connecting TypeScript backend in EC2 to PostgreSQL RDS
I have a TypeScript backend running in a t3.micro EC2 instance. I'm using NPM as the package manager, and TypeORM to seed the database. I have a PostgreSQL database set up in RDS that I'm trying to connect to. In my local dev environment, I didn't have any problem seeding and running the backend and having it connect to RDS. However, in the EC2, it won't finish seeding when running npm run seed
which runs the script
ts-node -r tsconfig-paths/register src/seeder/seed.ts
Running npm run migration:run
runs the script
yarn run typeorm migration:run
and gives this error:
$ ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js migration:run
Error during migration run:
TypeORMError: No connection options were found in any orm configuration files.
at new TypeORMError (/home/ec2-user/backend/src/error/TypeORMError.ts:7:9)
at ConnectionOptionsReader.<anonymous> (/home/ec2-user/backend/src/connection/ConnectionOptionsReader.ts:46:19)
at step (/home/ec2-user/backend/node_modules/typeorm/node_modules/tslib/tslib.js:144:27)
at Object.next (/home/ec2-user/backend/node_modules/typeorm/node_modules/tslib/tslib.js:125:57)
at fulfilled (/home/ec2-user/backend/node_modules/typeorm/node_modules/tslib/tslib.js:115:62)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I'm not too experienced with this, but I've tried deleting node_modules, dist, yarn install, npm install. Any answers as to what I'm missing?
Hi,
Please check if the EC2 instance security group, if the inbound and outbound rules allow traffic from RDS DB instance.This document can help setup communication between your RDS and EC2 instance [1]https://aws.amazon.com/premiumsupport/knowledge-center/rds-connect-ec2-bastion-host/ [2]https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.Scenarios.html
i hear you want to connect to rds postgres from TypeORM. i have found documentation that will help you connect to Postgres from TypeOrm[3]https://stackoverflow.com/questions/56511947/how-to-connect-to-postgres-amazon-rds-from-typeorm
references [4]https://stackoverflow.com/questions/64011676/error-no-connection-options-were-found-in-any-orm-configuration-files
Relevant questions
Environment variables for a Node app running on an EC2 Instance
asked 6 months agoDeploying a Machine Learning Project with django and laravel as a backend.
asked 2 months agoConnecting TypeScript backend in EC2 to PostgreSQL RDS
asked 11 days agoHow to execute parallel dags in Airflow in EC2 Instance
asked 4 months agoUnable to use Session Manager on EC2 instances in a private subnet with SSM VPC endpoint
Accepted Answerasked 3 years agoHTTPS Front End on a different host connecting to AWS Elastic Beanstalk Backend
asked 4 months agoUnable to enter create read replica page for a MySQL RDS instance inside classic EC2
Accepted Answerasked 5 months agoHow do I allow EC2 Agent to retrieve Secrets from Secret Manager when using CodeDeploy?
asked 17 days agoConnect to RDS using SSM
Accepted Answerasked 2 years agoHow to give users a limited access time to a web app running on ECS/EC2
asked 2 months ago