I have an angular app with a Node server - no DB yet. How to deploy on AWS? - node.js

I'm not sure where and how to start with AWS for deploying, very confused at the moment. It seems like I deploy my server on Elastic Beanstalk, but then where does my build and static files go? S3 I'm guessing? Should I just follow the tutorial for Beanstalk? Thanks!

You can use Elastic Beanstalk to host your entire application including Static files where it will resides in the web server.
The downside of it is the performance for large scale applications where you can leverage AWS S3 and CloudFront. So if you are a starter with AWS, then I would recommend to consider Elastic Beanstalk for entire application hosting for the moment.

Related

Deploying PERN stack application with AWS

I developed a PERN (postgres, express, react, node) app that's running on my local machine and I want do deploy it using AWS. What is the "best" way to go about doing this if I want to be able to continuously deploy changes and handle the potential of scaling?
For Database you can use RDS https://aws.amazon.com/rds/
For Hosting you can use EC2 Instance of your own https://aws.amazon.com/ec2/
You should dockerize your app
And Optionally can set up a continuous deployment pipeline using aws-codepipeline and aws-codedeploy . You can also use github actions for this purpose.

Which is the best approach to deploy MERN stack app on AMAZON EC2?

I am googling a lot to be sure the best approach to deploy MERN stack app on aws ec2 ... in some examples Nginx being used in server (expressjs) part and in some cases its being used for Recatjs part and the express js part is just hosted in node , React even can be hosted in s3 I guesss .. so what is the best approach however?
Without configuring the server yourself in EC2, you can simply use managed Node.js hosting provided by AWS Elastic Beanstalk.
If you want to directly configure EC2 instance and deploy, you can follow this tutorial to do the deployment https://jasonwatmore.com/post/2019/11/18/react-nodejs-on-aws-how-to-deploy-a-mern-stack-app-to-amazon-ec2

Is it recommended to use Docker with AWS Elastic beanstalk?

I'm deciding how to deploy my Nodejs API to AWS Elastic beanstalk. I have 2 options: deploy it as a normal nodejs service or deploy the api dockerized.
In which situations is it more recomendable to use docker over a normal nodejs service? (Giving the fact that I will use Elastic beanstalk)
Running your NodeJS as a Docker container in Elastic Beanstalk will definitely give you more control over your application.
However, it depends how much time you want to invest. Their maybe slightly more time in deploying with Docker, especially if you haven't used it before.
In which situations is it more recomendable to use docker over a
normal nodejs service? (Giving the fact that I will use Elastic
beanstalk)
First, if you really interested to run docker container in AWS, then ECS is what you need to run your application, lot of reason to run docker in ECS over elastic beanstalk
Serverless (faragate)
Scaling
Container management
Ci/CD with code deploy etc
Amazon Elastic Container Service (Amazon ECS) is a fully managed container orchestration service. Customers such as Duolingo, Samsung, GE, and Cook Pad use ECS to run their most sensitive and mission-critical applications because of its security, reliability, and scalability.
AWS ECS getting-started
docker is recommended if you manage multiple environments in short as its not simple question to answer but better to go with Docker as this what future deman, if you just want to want to run dev like environment then elastic beanstalk is fine.

How to deploy Node.js Express server + Vue.js app on AWS EC2

I'm setting up my website which would run on an AWS Ubuntu EC2. It is a Vue.js SPA relying on a Nodejs Express app with API calls and socket.io. So far both apps are working, the backend is on my AWS EC2 free tier, behind an Elastic Load Balancer, the frontend is on my machine since I working on it. Now I would like to deploy the frontend to my AWS EC2 also but I'm confused how to do it correctly. The tutorials I've found are using nginx but I'm not sure that I need nginx as I already have AWS ELB. Any advices would be great :)
as is says "If you are developing your frontend app separately from your backend - i.e. your backend exposes an API for your frontend to talk to, then your frontend is essentially a purely static app" here
I would choose s3 to host vue app because it's static and can be served using s3 and
I will choose EC2 for hosting my API (server code) and also i'd make an elastic IP to talk to my ec2 server so that on restart i don't have to handle the dynamic IP's
Steps to make your website live
First pull yout node express server on your ec2 instance
start your node express server use pm2 to serve it as an service
expose the served port from security groups of the ec2 instance
make an s3 bucket on aws and upload files to it
Tip: just click upload button after dropping your files to s3 do not go clicking next
after uploading select all the uploaded files and then mark as public
after uploading go to properties of that bucket and then choose static web hosting and type index.html the asked field
** TIP: do not use a load balancer for this application use only when you distribute your system across multiple ec2's**

Deploying react web application on AWS

I am looking to deploy my nodejs React web application on AWS. Currently I deployed my application on Microsoft's Azure and there is was pretty simple. I just had to add an App Service and give my git repository as the source to it. That took care of hosting my application. I am not getting a way like to do it on AWS. I am looking for something like that. How should I do it in AWS?
You can use AWS Elastic Beanstalk for this. Elastic Beanstalk is the PaaS offering which is an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS. It is similar to Microsoft Azure App services.
You can simply upload your code and Elastic Beanstalk automatically handles the deployment, from capacity provisioning, load balancing, auto-scaling to application health monitoring. At the same time, you retain full control over the AWS resources powering your application and can access the underlying resources at any time.
You can go through the tutorial for deploying your node.js app here- Deploying an Express Application to Elastic Beanstalk
One of the easy ways to do this in a Serverless manner is to use the new AWS Mobile CLI:
npm install -g awsmobile-cli
Then initialize and publish:
cd ./myproj
awsmobile init #answer some questions
awsmobile publish
This will setup an S3 bucket with CloudFront configured as your CDN to host your web assets. Your NodeJS app can be hosted in a Lambda function which is protected by API Gateway. A good way to configure the connection and authorzation from the client is to use AWS Amplify in your React application:
npm install aws-amplify --save
npm install aws-amplify-react --save
Then after doing an Amplify.configure(your_config_object you can connect to API gateway which calls your Lambda:
let apiName = 'MyApiName';
let path = '/path';
let myInit = { // OPTIONAL
headers: {} // OPTIONAL
}
API.get(apiName, path, myInit).then(response => {
// Add your code here
});
This will be a signed request to your AWS resources.
More here:
http://docs.aws.amazon.com/aws-mobile/latest/developerguide/web-getting-started.html

Resources