How can I connect to my redshift cluster using Node.js? - node.js

I am trying to connect to one of my Redshift clusters so that I can fetch data from one of the tables there. I am using Node.js for it.
I used the createCluster() method and created a cluster, but I cannot seem to find a method to read from/connect to it. The aws docs are rather confusing for me as I am new to the aws environment.
How can I connect to an existing cluster and get some data out of a table in it?
Thanks :)

npm i node-redshift
you can connect using this npm name node-redshift
https://www.npmjs.com/package/node-redshift
OR
regarding the AWS, i think this will help you
Trying to Connect to Redshift Over AWS Lambda

I was trying to make the 'node-redshift' module work before I asked this question here. I found out what I was missing out on. I had to have a security group associated with my cluster. There was no option to create a security group in my region (Asia Pacific - Mumbai). I changed the region and was able to create the group, set the appropriate port and IP and it worked.

To those who are using node-redshift, it was working fine with 12.13.1 but was not responding for 14.15.0 LTS.
Maybe you may want to check your Node version once.

I was able to connect AWS-Lambda to Redshift importing 'node-redshift' module into the Lambda Function. The most important thing while creating lambda layer try to make the layer for 'node-redshift' package for version nodejs10.x. I tried adding the layer for nodejs14.x and was struggling to make a connection to Redshift which was not happening. So after changing the version from nodejs14.x to nodejs10.x it worked. Moreover thanks to Vijender R, his answer also gave me the direction to change the versioning for working with the 'node-redshift' package.

Had the same issue, the reason - I've updated node.js. After returned it to version 11.1.0, everything works ok.
The solution is to find something instead node-redshift (since it was updated 4 years ago)

It may be worth trying to use https://www.npmjs.com/package/#aws-sdk/client-redshift-data, which seems to be maintained by AWS itself.

Related

Nodejs Backend APIs, when dockerized, are taking more time to connect to mongodb

I moved my nodejs backend to docker(previously it was deployed on ec2 instance).
My mongodb is deployed on another ec2 instance, which i did't move to docker. (want to keep it this way only).
After dockerization of my backend,(Deployed it on ECS) APIs are taking longer time for db queries. Don't understand what went wrong. Or is it suppose to be like this? Any suggestions?
So, I found the issue here.
Due to different availability zone, It was taking more time. There was one extra hop causing extra time.

AWS - Steps/Consideration for migrating to latest generation of ec2 from an older generation

I am looking at upgrading from older generation ec2 to the latest generation for example m3.medium to m5.large. Are there any steps or considerations that need to be made when making this change? I couldn't find any documentation that is linux specific, only windows specific: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/migrating-latest-types.html.
If anybody could help me I would really appreciate it.
To upgrade the instance type on AWS I usually follow this official doc
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-resize.html
However it also depends on the complexity of application running on your instance viz. just an apache server or a database? To handle that situation as #Marcin mentioned, always start with AMI of your instance and try doing any change before applying directly on production instances.
screenshot from the official doc

Change db instances in ForestAdmin and Lumber

As admin part I want to use ForestAdmin.
Also I am gonna use already existing database (Mattermost`s actually).
Everything was deployed to AWS (ForestAdmin and Mattermost).
Due to tutorial I can install ForestAdmin via Lumber and connect it to existing db. Actually I have done this, do some playing with code to expand some functionalities.
The main question is: when I install ForestAdmin locally via Lumber - I point to my local instance of database and lumber generates code (models and CRUD). So also I can install ForestAdmin locally and point to Mattermost`s database on AWS. BUT can I somehow change which database I want to use - local or that one on AWS?
Maybe I explain this problem bad - so also I will try to rephrase with example of desired flow:
Mattermost with database already installed on AWS
ForestAdmin also installed via Lumber and connected to Mattermost`s db
I got local instance of Forestadmin and Mattermost, write some code, test it in local environment.
Push to repo, connect via ssh to AWS and pull changes which was made.
AWS instances works as local but with separate instances of db.
Or maybe there is some better way to push changes from local Forestadmin and pull it to AWS instance of Forestadmin?
Thanks for any help in advance!
Yes you definitely can, you can use Forest environment for that :
https://docs.forestadmin.com/documentation/reference-guide/how-it-works/environments

Deploy MongoDB cluster, node, express, mongoose app on AWS

I have been trying to deploy a Node.js web app which uses mongoose and express on AWS for a week now.
I'm new to AWS and am not the best networker, so please have patience with my lack of networking understanding.
So far I have used AWS's Quickstart Guide to launch a new VPC with mongoDB.
Found here: http://docs.aws.amazon.com/quickstart/latest/mongodb/welcome.html
I verified that the mongo database was working by ssh'ing into the private mongo IP's through the NAT gateway (using the keypair). It appears to be working fine and I have a username and password for admin level of the mongodb setup.
I then launched an elastic beanstalk node.js application within this VPC (or at least I think it was in here - the security rules include the subnets of the mongodb), with a call in my code as follows:
mongoose.connect('mongodb://<MongoUsername>:<MongoPassword>#test.amazonaws.com:27017/admin')
where admin is the database name.
When I try to launch this node.js instance though, it does not run.
I have, however, verified that the node.js app runs independently of the VPS by launching a completely separate elastic beanstalk instance. It runs my code fine (but obviously doesn't connect to a db so forms do not work.)
What am I missing here? Why can I not connect this cluster to my node app? I'm super confused and frustrated with the whole process and would really appreciate any advice. Thanks.
If you need any further info to help me debug this let me know.
Edit: To the person who wants this closed as too broad.. what extra information do you want? I specified in the question that im new at this and to tell me what else you need.. so I find this classification without any clarification pretty rude and unhelpful. Cheers
So this issue here was that I was not applying the correct security rules to my elastic beanstalk instance and it was therefore not rendering to the Ip.
Thanks to those that tried to help, if anyone has a similar issue and needs a hand, feel free to message me.

Unable to copy RDS parameter group across regions

I am using the RDS command line tool from here and am having trouble copying the parameter group to a different region. Running the rds-copy-db-parameter-group fails with the following error:
rds-copy-db-parameter-group: Could not find the resource you requested: DB ParameterGroup not found, not allowed to do cross region copy.
The command I am using is:
rds-copy-db-parameter-group arn:aws:rds:ap-southeast-1:myAccntId:pg:myParamGroup-utf8mb4 -t copyOfMyParam -td testcopy
I'm pretty sure the ARN is correct and the parameter does exist. Is this a problem with the tool or aws? Is anyone else encountering a similar issue?
I ran into this same issue recently and opened a support ticket with AWS. The response I got was that the RDS team added this feature to the documentation but haven't yet built the actual support for this feature.
This bothered me a lot and ate up a couple of hours so I put this simple script together. There's loads of room for improvement so please share if you improve upon it or find issues!
https://gist.github.com/phill-tornroth/f0ef50f9402c7c94cbafd8c94bbec9c9

Resources