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.
Related
I am currently learning about docker and have read a few conflicting articles about the process so thought I would ask the oracles here for answers.
Having setup my app I use Node as the server, which handles the routing and API connection to Mongo just fine on my localhost, a few articles have said that you do not use Node on production so one of my friends followed a tutorial that introduces nginx to the equation
While his app loads the static content, he has lost the dynamic side of things, items in the database are not loading in for example.
First question is, does nginx take over from Node or add to it in these instances?
To me it seems that node is still involved to serve the content so express and mongo should also still work and my hope is theres some config that we haven't found that's the blocker.
Second question is, if my assumption is correct, and nginx is simply being introduced as well as Node, is it the server, is node the server or am I missing the relationship between them somehow. The tutorials and articles usually refer to nginx as the server hence the confusion.
My end goal is to work out how to use my Linode lab, setup docker and then have my angular app running in a publicly accessible way. I think I have the docker side of things worked out but my head isn't figuring out how things work after that with node and nginx - especially when my previous experience is with regular old servers with php and sql.
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.
I have lately been learning React and Node js and have been having a lot of fun. I am wanting to deploy / publish my work onto the internet using Amazon AWS (to share my app with friends and potential employers). However, I am having trouble.
I have researched this process quite a bit and can't seem to find any resources that are detailed enough and that touch each aspect of my web app. To clarify, my front end is written in React and my back end is in Node/Express js, and that is connected to a MySQL database. Currently all of this is stored locally on my computer.
I'm not sure how to proceed...I've played around with adding all my code to github and running through the deploy feature on AWS Amplify, but that seemed limited to the react front end (at least I could not discover anything about including the functionality of my back end and including my database connection AND queries from Node).
Can anyone point me in the right direction? Providing any tips, suggestions, and/or resources to aid in this process would be appreciated. Specifically to this question: How to I deploy my React, Node/Express, and MySQL web app (currently stored completely on my local computer) to the internet through Amazon AWS?
To generify the question a little: you want to deploy a frontend, a backend and a database to AWS.
(Un)fortunately, there are lots of different options for this. Let's explore a little.
Frontend
Assuming that your frontend is a set of static resources (html/js/css), you don't need much more than a web server. You can use either S3 (an object store that can also serve web sites), or Cloudfront (a content delivery network), or run a virtual machine on EC2, install a web server there and deploy your frontend there.
Backend
Lots of options here. You can package your app in a Docker container and use ECS (container service or EKS (kubernetes service). You could also run your backend on Elastic beanstalk (comparable to Heroku). Or, run a virtual machine on EC2 and deploy your backend there.
Database
You can choose between a managed/hosted database like RDS, or roll your own by installing it on a virtual machine and installing a database server there.
So, what to pick? It depends on what you're comfortable with. If you have a bit experience with managing Linux servers, you could start an EC2 instance, install a web server like nginx or apache, install NodeJS, install MySQL and then copy your frontend, backend and database scripts/backup to the server.
If you're not comfortable with managing Linux servers, you could go for hosted/managed solutions like S3, Elastic beanstalk and RDS.
Do that, that when your frontend is running on a different domain/url than your backend, your backend needs to set CORS headers otherwise the browser won't allow your frontend to make HTTP requests to your backend.
Hope this helps - good luck!
Elastic Beanstalk (EB) could be a good start, as it can provision all resources that are needed for node.js applications, without much knowledge required about setting up and managing everything from scratch:
Deploying Node.js applications to Elastic Beanstalk.
For simplicity you can start with single instance environment type (no load balancer) and see how it goes.
EB can also setup a database for you:
Adding a database to your Elastic Beanstalk environment
If you get more comfortable about working with AWS, you can scale up into load balanced EB environment, or look at other options, such as your own EC2 instances with autoscaling groups, load balancers, container services and more.
AWS is new to me. I want to configure three VM on AWS to run one node.js app.
I want to set three VMs to run MongoDB, Memcached and node seperatedly.
The question description says that You
should also carefully configure the security groups inside of AWS, so that only your node instance can access your mongo and mcd instances, and so that your node instance is only reachable on port 8080.
When I am setting the security group, I feel really confused. If somebody can tell me how to configure this?
PS: I wanted to comment to OP's question, but I can't as I don't have enough reputation.
You need to go through some docs on AWS to understand this. If you are building enterprise level app you want to look into this docs where you can get more info on security groups and how you can setup your architecture on AWS with security.
Secondly, Security groups are the rules which are applied on instance level - consider as firewall, for your system more info here. In your case you can open node.js ports for mongodb (27017/18 TCP) and Memcached (11211 - TCP) instances as node only requires to connect to mongodb and memcached, also you can setup NAT if you want to keep your instances in private subnet.
I have an ElasticBean application running (setup with NodeJS) and I wondered what the best way to integrate MongoDB would be. As of now, all I've done is ssh into my eb instance (with the eb cli) and install mongodb. My main worry comes from the fact that the mongo db exists in my instance. As I understand it, that means that my data will most certainly be lost as soon as I terminate my instance. Is that correct? If so the what is the best way to go about hooking en EB app to a MongoDB? Does AWS support that natively without having to go rent a DB on a dedicated server?
You definitely do NOT want to install MongoDB on an Elastic Beanstalk instance.
You have a few options for running MongoDB on AWS. You can install it yourself on some EC2 servers (NOT Elastic Beanstalk servers) and handle all the management of that yourself. The other option is to use mLab (previously MongoLab) which is a managed MongoDB as a Service provider that works on AWS as well as other cloud services. Using mLab you can easily provision a MongoDB database in the same AWS region as your Elastic Beanstalk servers.
Given the steps involved in setting up a highly-available MongoDB cluster on AWS I generally recommend using mLab instead of trying to handle it yourself. Just know that the free-tier is not very performant and you will want to upgrade to one of the paid plans for your production database.
Been there, done that. As #MarkB suggested it´d be a lot easier to use a SaaS instead.
AWS by itself doesn´t have a native MongoDB support but deppending of your requierements you could find a solution with little or no extra cost (beside EC2 price) on Amazon Marketplace. These images are vendor´s pre-configured production-ready AMIs of popular tools like MongoDB.