Can AWS S3 hold a node js app? Because I have a front-end serverless app, and don't know how to let it interact with lambda function
You can store a NodeJS codebase in S3 but it won't be executed since S3 is for the purpose of serving static content. If you want to have a NodeJS environment in AWS there are couple of options available.
EC2 instance with NodeJS
Using Elastic Beanstalk
Using AWS ECS (If you plan to dockerize the NodeJS app)
AWS Lambda (This you need to tailor your application to fit in)
Related
I have a react app stored on an AWS S3 bucket and it seems to be working fine.
I have an RDS database that is up and running and I have the end point for it.
I have a node app that is running express and everything needed to take a request from the front end and "place" the data in the RDS database using that end point.
My question is - When the node app is deployed to the S3 bucket, what URL do I use in the front end to call the node app back end in the S3 bucket?
We have a similar setup at my work and the end point for calling the back end (S3 bucket with Node) from the front end is something like ...
https://xxxxxxxxx.execute-api.us-east-2.amazonaws.com/dev
https://xxxxxxxxx.execute-api.us-east-2.amazonaws.com/prod
I am not sure if I need to set up an api gateway or something to facilitate the routing of the call?
As mentioned in the comment, AWS s3 are for just static content. So you can only deploy a static websites on AWS s3 but not the nodejs app, as it will need node as a runtime.
If you want to replicate, then as mentioned its must be behind API gateway. so you need to understand the nderlying deployment resources which can be lambda, ecs or ec2. API gateway just route your traffic to the deployment.
AWS API Gateway
If you are just trying to run your backend with a few steps then AWS EC2 or AWS lightsail is the quicker option.
Ec2:
With EC2 you will need to configure and install each and everything for example nodejs runtime, npm etc
lightsail:
In lightsail you just need to select the node version and that's it.
Here are few docs that can help you to deploy your app using lightsale, lightsale instance come with nodejs version and does not need any installation, you just need to copy your code to the instance and start.
Once you able to deploy the app either on ec2 or lightsale, you just to copy the public IP from lightsale or ec2 and use that IP in the frontend app.
deploy-nodejs-app-in-aws-lightsail
amazon-lightsail-quick-start-guide-nodejs
deploy-node-js-server-on-aws-lightsail
I am new to AWS. I have my node/express.js backend hosted on the Elastic beanstalk and it's working as per expectation. The express.js APIs communicate with the AWS RDS MySql database and send response accordingly. I have integrated the APIs calls in the React frontend and it is working fine locally. Now I have deployed the React frontend on the amplify and React app is hosted there now. But the API calls to elastic beanstalk are failing on the Amplify with the response "TypeError: Failed to fetch". I have also analyzed the Elastic beanstalk logs but could not find anything there. I wanna know why API calls are working perfectly locally but not on the amplify?
I think the issue is that Elastic Beanstalk requires that the communnication protocol has to be the same for both sender and receiver. So, the solution is to use either HTTP or HTTPS for both Front-End and Back-End.
I have deployed nodejs app on ec2 instance. I have used atlas for mongoDB, load balancer, Aws ssl to secure the connection and pm2. As iam already using aws load balancer should i need to use nginx. What is the best practice of deploying nodejs app on ec2. if i need to use ngnix where to configure http to https redirect?
Looks like you need a web application to be developed. I would suggest below architecture. enter image description here. This will eliminate pain of hosting/maintaining servers.
All AWS components can be programmatically integrated using AWS SDK and Amplify is a wrapper on top of this.
Develop your UI in any JavaScript framework and host it in AWS S3. Using CloudFront you can cache the UI layer. Put an API gateway layer which will intercept all the traffic from your UI. Using AWS Amplify can very much simplify your UI development with a lot of built-in wrapper components. It comes with CLI which can be used for deployment as well.
Host your Spring Boot+DB Driver (or NodeJS/C#/PHP/Python/etc.) Application with Rest API in AWS Beanstalk. BeanStalk can be configured with Load Balancing, Auto Scaling Group, etc. If AWS Beanstalk seems complicated for you, consider using AWS Lambda (Serverless, microservices) architecture.
AWS DocumentDB is a MongoDB extension and maybe you can leverage it. Which is again a highly scalable, very flexible NoSQL in this case.
You can leverage AWS Cognito (https://www.slideshare.net/awsugkochi/acdkochi19-enterprise-grade-security-for-web-and-mobile-applications-on-aws)to store User credentials in groups and add permissions and authenticate/authorise the users.
In API Gateway you can configure AWS Cognito Authoriser and protect the APIs from un-authorised calls.
Some of the auxiliary services can be used to integrate email/SMS etc. AWS SNS (Pub/Sub) + SQS (Queue) -> If you want to decouple any process, you can use SNS + SQS. You can send e-mails using AWS SES. AWS Route53 is the DNS and your domain can be hosted here.
If you have to upload any files to cloud and store it for users, leverage AWS S3.
You need to protect internet-facing components like API Gateway and Cloudfront using AWS WAF.
All these systems generate logs and it can be accessed from AWS cloudwatch. Your APIs can be monitored for performance and errors using AWS X-Ray.
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**
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.