BuyAmazonCreditAccount

A Beginner’s Guide to AWS and EC2

Hello and welcome to our journey through Amazon Web Services (AWS)! Whether you’re a complete newbie to AWS or just looking to refresh your knowledge, you’ve landed in the right place. This blog series is crafted with beginners in mind; we’ll start from the basics and gradually delve into more complex topics. Ready to embark on a comprehensive exploration of AWS’s essential services? Let’s dive in!

What We’ll Cover Today:

  • A beginner’s introduction to Cloud computing
  • Creating your AWS account
  • Understanding Regions and Availability Zones
  • Getting started with EC2 (Amazon Elastic Compute Cloud)
  • The basics of SSH and Security Groups
  • How to deploy a Node.js server on the internet
  • Terminating your EC2 instance to avoid charges

If you are an absolute beginner and never heard anything about AWS then this is the perfect starting point for you Then Buy amazon AWsS account 

The Cloud Basics

Imagine you’ve developed a Node.js application that runs on port 8080. You want it accessible worldwide. Traditionally, this meant purchasing a static IP, keeping your hardware running 24/7, and managing all the IT maintenance and security risks yourself. But thanks to cloud services like AWS, these burdens are significantly reduced.

Setting Up an AWS Account

Creating an AWS account is straightforward—similar to setting up a social media profile but with a payment method needed for initial verification (like a small Rs 1 charge). Make sure international transactions are enabled on your card!

Regions and Availability Zones Explained

Regions: AWS hosts data centers worldwide, grouped into Regions, which are separate geographic areas. Each Region operates independently, helping reduce latency and comply with local regulations. For instance, if your target audience is in India, you’d ideally set up in the Mumbai region (ap-south-1) for optimal performance.

Availability Zones: Within each Region, there are multiple isolated Availability Zones, which help enhance reliability and fault tolerance of your applications.

Mumbai has three such zones:

ap-south-1a,

ap-south-1b,

and ap-south-1c.

Diving Into EC2

EC2 allows you to run your applications on a virtual server in the cloud—imagine it as renting an online computer where you can launch your apps. AWS offers a free tier for beginners, so you can learn without worrying about costs.

You can check the pricing of AWS EC2 here.

You can check free-tier resources here.

Instance: An instance is a virtual server in AWS. It runs an operating system (like Linux or Windows) and can be configured with different amounts of CPU, memory, and storage. We will use Linux Ubuntu for our blogs.

Instance Type: This defines the hardware specifications of the instance, like the number of CPUs, amount of RAM, etc. Examples include “t2.micro” (a small, general-purpose instance) and “m5.large” (a more powerful instance). Don’t worry, we will see all these in practice in this blog.

Elastic IP Address: A static, public IP address you can associate with your instance, allowing it to be reachable from the internet.

Security and Connectivity

Security Groups: These firewalls dictate what traffic can enter or leave your EC2 instances. You can set rules that restrict or allow access based on IP, port, and protocol.

SSH (Secure Shell): SSH lets you manage your EC2 instance from your computer. You’ll set up a key pair for secure access and use SSH commands to interact directly with your EC2 machine.

Deploying a NodeJS Application on the Internet

Let’s get your NodeJS server up and running on the web!

Here’s a simple NodeJS server example:

javascriptconst express = require('express');
const app = express();
app.get("/", (req, res) => {
res.send("Welcome to AWS tutorial by Shivam Bhadani");
})
app.get("/health", (req, res) => {
res.send("Everything is OK");
})
app.listen(8080, () => console.log("Server is listening on Port 8080"));

Don’t stress if the code seems complex—it’s just a basic server that responds on port 8080. You can grab the full code from this GitHub repository.

Steps to Launch Your NodeJS App on AWS EC2:

  1. Start in the AWS Console: Navigate to the EC2 service by typing “EC2” in the search bar and click on ‘Launch Instance’.

  1. Set Up Your Instance: Name your instance and choose ‘Ubuntu free-tier’ as the OS image. Pick an instance type; for beginners in the Mumbai region, ‘t2-micro’ is a good free-tier option.

  1. Security Group Setup: Scroll down and opt to create a new security group. This acts as a virtual firewall. For simplicity, give it access to ‘Allow SSH traffic from anywhere’, which enables you to SSH into your instance from any computer.

  1. Key Pair Creation: Further down, create a new key pair. This is crucial for SSH access. Download this key pair to your computer—you’ll need it to connect securely.

  1. Configure Storage: By default, an 8 GB storage setting is sufficient to get started. We’ll explore Elastic Block Store (EBS) more in future discussions.

  1. Launch Your Instance: Click on ‘Launch Instance’ and wait a couple of minutes for your instance to start running. Congratulations, you’ve just set up your first EC2 instance!
  2. Connect via SSH: From the EC2 dashboard, select your instance and click the ‘Connect’ button. If you prefer using the AWS console directly for access, select ‘EC2 Instance Connect’.

  1. Using SSH from Your Computer: For those connecting via their own computer, switch to the ‘SSH client’ tab in the connect dialog. You’ll need to move your downloaded key pair file to a directory from where you can run SSH commands, such as the root directory:
    bashcp /mnt/d/shivam-security-group.pem ~/
    Now, execute the SSH commands provided to establish a secure connection.
  2. Verification: Once connected, your local terminal becomes the terminal of your EC2 instance. You can confirm this by matching the IP addresses displayed.
  3. Setup Your Environment: Now that you’re connected, it’s time to set up your server environment. Install NodeJS and npm using the provided commands.

This step-by-step guide will help you get your NodeJS application running on an AWS EC2 instance, making it accessible to anyone on the internet. Dive in, and see your application come to life in the cloud!

Conclusion

By the end of this blog, you’ll have a good understanding of the cloud basics, how to set up and secure your AWS environment, and the initial steps to getting your application running online. Stay tuned for more detailed discussions in upcoming posts, and don’t hesitate to dive into the hands-on experience with AWS!

Buy amazon AWsS account 

Scroll to Top