Synopsis
In this blog post, I’ll walk you through the steps to deploy a Node.js application on the AWS cloud. Along the way, I’d demonstrate how to leverage Termius, a versatile SSH platform that works on both mobile and desktop. Additionally, I’ll guide you on how to communicate seamlessly with a GitHub repository. Let’s dive in!
Backstory
Deploying a Node.js Application on AWS means putting your web app on a super reliable and fast platform. It’s like giving your app a strong backbone. It can handle lots of users without slowing down. AWS also gives you handy tools to make deploying and managing your app easier. This way, you can spend more time making your app cool and less time worrying about technical stuff. So, using AWS for deployment helps make your web app strong, reliable, and ready for anything.
Requirements
An AWS Account
Termius (SSH platform for Mobile and Desktop)
Basic Understanding of Linux
A GitHub Account
Node.js
Node.js is a runtime environment that allows you to run JavaScript code outside of a web browser. It is built on the V8 JavaScript engine, which is the same engine that powers Google Chrome. Node.js enables you to execute JavaScript on the server-side, making it possible to build web applications, APIs, and other types of software using JavaScript.
Termius
Termius is a cross-platform SSH client that allows users to securely connect to remote servers, manage files, and execute commands over SSH (Secure Shell) protocol. It’s available for both mobile devices and desktop computers, providing a convenient way to access and manage remote servers from various platforms.
Express
Express is a web application framework for Node.js. It provides a robust set of features to help you build web applications and APIs quickly and efficiently.
Procedure
This process can easily be replicated by anyone on their local machine by following closely with the instructions that would be listed below.
- Create an AWS instance Login to your AWS console and create an ec2 instance, select an Ubuntu OS image and ensure the Amazon Machine Image (AMI) and instance type (t2.micro) fall under the free tier to avoid incurring charges.
- Create a new key pair You can also use an existing one if available, click on create a security group and allow SSH traffic from the recently created security group, finally click on “Launch instance”.
- Connecting the ec2 instance to termius Take note of the instance public ip address and the user name as they would be integral in connecting to Termius. If you do not have Termius, you could download it here.
- Next I created a new host on Termius and input my ec2 public IP address and select a key pair by using the already created file from the AWS console. Finally I click on the arrow on the top right corner of the screen.
- Click on the node-server icon, lick on “Add and continue” to connect to your instance.
- Connecting to GitHub Create a new directory called “node-server” via the terminal.
Create an ssh key generator to connect to your GitHub account.
Get the created ssh key, copy it and head to the following GitHub Repo: https://github.com/BlacOrpheus/Dating-App. Click on settings and click on deploy keys
- Add your keys there and allow write access.
- Clone your repository into your ec2 instances
Click on code and copy the SSH code.
- On Termius type the following code:
git clone git@github.com:BlacOrpheus/Dating-App.git
- Proceed to install node on your AWS EC2 instances with the following commands:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
. ~/.nvm/nvm.sh
nvm install --lts
- Installation of Dependencies
The application functions with a dependency know as Express. Install express with the following command:
npm install express
- Deployment of Application
node index.js
Conclusion
Deploying a Node.js app on AWS offers a reliable and scalable hosting solution. With AWS’s powerful infrastructure, handling high traffic is an easy task. Plus, it’s cost-effective and flexible. By following the steps in this guide, you’ll be all set to launch your Node.js app on AWS.
Chidubem Chinwuba is a dedicated Cloud/DevOps Engineer. He possesses a deep passion for technology and its transformative potential across industries. Overall, Chidubem is driven by his passion for technology and his aspiration to make a meaningful impact in the Cloud/DevOps domain. He is excited to continue his professional growth and contribute to projects that shape the future of technology.
Top comments (0)