Connect to postgres RDS from ec2 using Sequelize - node.js

I created an ec2 instance, in default VPC, and configured my node.js project as I do on my local machine.
I created RDS postgres instance in the default VPC and permitted all the traffic. After this I tried to run migrations from ec2 with "npx sequelize-cli db:migrate" but the answer was only:
Sequelize CLI [Node: 14.2.0, CLI: 5.5.1, ORM: 5.21.2]
Loaded configuration file "database/config/config.js".
Using environment "development".
Than I connected to the db from my local machine and run the same command and it worked also installed psql on EC2 instance and I can connect to the RDS instance and see all the tables created from local machine.
When I run migrations from local machine I get the answer above plus the logs from migrations.
It looks like I am not able to connect to RDS instance from ec2 using sequelize but using psql it works.
Also, it works to connect to RDS using node server on ec2 but sequelize cli doesn't.
Environment
Sequelize version: 5.21.2
Node.js version: v14.3.0
Operating System: ami-0a9e2b8a093c02922 and Ubuntu Server 18.04 LTS same behaviour
What should I do to run migrations from ec2 using Sequalize?

Solution for this problem is to install a version < 14 for node js. Install nvm ( node version manager) on the EC2 and then install a node js version < 14. Run again npm install in the project folder and then run the migrations + seeds and all should work.

Try a different Linux distribution on EC2.

Open a bug report with sequlize on github if nothing else works.

Related

Run docker on AWS Elastic Beanstalk NodeJS server

I have Elastic Beanstalk environment for NodeJS application
Platform Node.js 16 running on 64bit Amazon Linux 2/5.6.1
I need to run phpmyadmin by docker on this environment
I try to run phpmyadmin by docker, but can't install it , for this I use the code below:
Is it possible to install and run docker on nodejs platform using hooks or other ways?

I am having issues while deploying react and node application on unix standalone server

I have developed my application on a windows machine and have to deploy this on a standalone UNIX server and while running commands like: npm start, it says that package is not available but I checked and everything is available in the project's npm modules.
Do I need to use docker or how can I achieve that without any container such as docker or kubernete.
Can I try cloning my repo in some other Linux machine and npm install and then use the same folder to deploy on UNIX CentOS running on the server?

How to run eb init specifying node.js version 8?

I run eb init and deploy, I get the node.js version 6, how can I specify that I want node.js version 8 when executing eb init command?
This is an interesting question and I would love to know if there's an easier way, but here's how I got it working:
Determine the latest SolutionStack name as listed here. Presently, this is "64bit Amazon Linux 2017.09 v4.4.4 running Node.js".
Perform eb init -p "64bit Amazon Linux 2017.09 v4.4.4 running Node.js"
create a .ebextensions directory.
create a file .ebextensions/nodejs_version.config
add the following snippet to it:
option_settings:
aws:elasticbeanstalk:container:nodejs:
NodeVersion: 8.9.3
eb create
Once the environment has begun building, you can execute:
aws elasticbeanstalk describe-configuration-settings \
--environment-name <environment-name> \
--application-name <application-name>
Look for option settings in the aws:elasticbeanstalk:container:nodejs namespace and you should see the NodeVersion assigned to 8.9.3.
Ideally, "64bit Amazon Linux 2017.09 v4.4.4 running Node.js" itself should identify the latest version; you shouldn't need to add an option setting for this, unfortunately that is not so.
Please check below link for supported version of node.js:
Elastic Beanstalk supported platforms
Then you can use below command with your specified version:
eb init myapp --platform node.js-16
open the config file in the elasticbeanstalk directory and put the version you
Use the -p parameter
eb init -p "node.js 8.9.3"
Or any other version that is supported

Elastic beanstalk and Angular 2

Is it possible deploy an Angular 2 application on Elastic beanstalk?
I'm trying to packaging an application but I have the following problems:
npm is not installed on the machine, I had to install it manually connecting via ssh, I'm wondering if there is an automated way to install it.
The version od node was wrong, I had to manually update too, also in this case I'm wondering if there is an automated way to update it.
When finally the application starts on the port 8081 using browser-sync, I get an error because this port seems already to be in use.

node.js commands on AWS elastic beanstalk ec2 server

I created an elastic beanstalk node.js app on AWS, which created the EC2 and RDS server for me. I am using putty to connect to my Linux EC2 instance, which is successfully logged in.
But the following command doesn't work:
node -v
npm install express -g
node
it gives me an error:
bash: node: command not found
Node is automatically installed on your instance for elastic beanstalk. It's not in the path.
Look for node installation under /opt/elasticbeanstalk/node-install/ folder.
You shouldn't be installing modules from command line. The preferred way to install node modules on elastic beanstalk is thru package.json. Dependent modules are automatically installed on the instance by aws.
you should find out which node version is being used right now. Then you can use that in your PATH and use npm/node binary..
grep node /var/log/nodejs/nodejs.log
export PATH=$PATH:/opt/elasticbeanstalk/node-install/node-v6.11.5-linux-x64/bin/
Assuming you're using Amazon Linux 3.4:
> rpm -Uvh http://download-i2.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
> sudo yum install nodejs npm --enablerepo=epel
That should do it.
You can find out where node is installed, and npm, by running ps aux | grep node. This will show you the directory it is being run out of. This is how they give you the ability to pick your version of node, by installing multiple versions. But as palanik says, no need to try to do this manually, unless you are trouble shooting. Which is the PITA on AWS, but that's another discussion.

Resources