Logo

dev-resources.site

for different kinds of informations.

Deploying a Node.js Application on AWS

Published at
11/23/2024
Categories
node
aws
termius
awscommunity
Author
blacorpheus
Categories
4 categories in total
node
open
aws
open
termius
open
awscommunity
open
Author
11 person written this
blacorpheus
open
Deploying a Node.js Application on AWS

Image description

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.

Image description

  • 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”.

Image description

Image description

  • 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.

Image description

  • 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.

Image description

  • Click on the node-server icon, lick on “Add and continue” to connect to your instance.

Image description

Image description

  • Connecting to GitHub Create a new directory called “node-server” via the terminal.

Image description

Create an ssh key generator to connect to your GitHub account.

Image description

Image description

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

Image description

  • Add your keys there and allow write access.

Image description

Image description

  • Clone your repository into your ec2 instances

Click on code and copy the SSH code.

Image description

  • On Termius type the following code:
git clone [email protected]:BlacOrpheus/Dating-App.git
Enter fullscreen mode Exit fullscreen mode

Image description

  • 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

Enter fullscreen mode Exit fullscreen mode
. ~/.nvm/nvm.sh


nvm install --lts
Enter fullscreen mode Exit fullscreen mode

Image description

  • Installation of Dependencies

The application functions with a dependency know as Express. Install express with the following command:

npm install express
Enter fullscreen mode Exit fullscreen mode

Image description

  • Deployment of Application
node index.js
Enter fullscreen mode Exit fullscreen mode

Image description

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.

awscommunity Article's
30 articles in total
Favicon
Navigating Generative AI Services on AWS: Your Essential Guide
Favicon
Choosing the Right AWS Machine Learning Service: A Comprehensive Guide
Favicon
Why AWS Decision Guides Matter for Cloud Computing Beginners
Favicon
Building a Stronger Security Posture with AWS Security Hub
Favicon
Streamlining Terraform Workflows with Atlantis on Amazon EKS
Favicon
Party Rock Application - GenAI
Favicon
MiniProject — Detect Faces by Using AWS Rekognition!
Favicon
How I Passed the AWS Certified AI Practitioner Exam ??
Favicon
Level up your AWS Cloud Skills with Free AWS Learning Knowledge Badges
Favicon
What Is The AWS Community Builders Program And How To Apply
Favicon
Becoming an AWS Community Builder
Favicon
Organizing a virtual AWS re:Invent@home: A Behind-the-Scenes Look
Favicon
Compute in the Cloud 🌥️🚀
Favicon
The Evolution of Modern Application Deployment : From Physical Servers to Kubernetes:
Favicon
Countdown to re:Invent is on: 5 days to go
Favicon
Deploying a Node.js Application on AWS
Favicon
Agile and DevOps Transformation: a Successor
Favicon
AWS CLOUD/DEVOPS OBSERVABILITY
Favicon
There's a new cert in town!
Favicon
How I passed the challenging AWS Certified DevOps Engineer – Professional Certification-2024.
Favicon
AWS All Builders Welcome Grant & re:Inforce Newbie
Favicon
Deploying AWS Guard Duty Malware Protection for S3 Buckets (Step-by-Step Guide)
Favicon
Monitoring Underutilized Storage Resources on AWS
Favicon
AWS Community Day 2024: A Landmark Event in Kenya's Tech Landscape
Favicon
AWS GameDay: Frugality Fest
Favicon
Understanding Version Control Systems
Favicon
Enabling AWS tags for billing
Favicon
Say Hello to the Automated Testing Assistant by Party Rock
Favicon
AWS Community Day Kenya
Favicon
Accelerating App Development with AppSync Gen2 & Generative AI

Featured ones: