Sunday, August 2, 2026

AWS EC2 Instance

EC2 in AWS

  • EC2 (Elastic Compute Cloud) is an AWS service that provides virtual computers/servers in the cloud.
  • You can use EC2 to run websites, applications, APIs, databases, and other software.
  • You can start, stop, restart, or terminate EC2 servers whenever you need them.
  • You generally pay for the AWS resources you use, with pricing depending on the instance and other resources.

What is an EC2 Instance?

  • An EC2 Instance is a virtual server/computer created using Amazon EC2.
  • It has CPU, RAM, storage, networking, and an operating system.
  • You choose an AMI to decide the operating system, such as Ubuntu or Amazon Linux.
  • You choose an Instance Type to decide how much CPU and RAM the server gets.
  • A Security Group acts like a firewall and controls incoming/outgoing network traffic.
  • You can connect to a Linux instance using SSH.
  • Each instance can have a private IP, and it can have a public IP when internet access is required.

Simple Example

EC2 = AWS service that provides virtual servers
Instance = One virtual server created inside EC2

How to Create an EC2 Instance in AWS

Think of an EC2 instance as a computer/server that you rent from AWS.

For example:

Your laptop has Windows and you install software on it.
Similarly, an EC2 instance is a computer in the AWS cloud where you can install Linux, Apache, websites, databases, Docker, etc.

Step 1 — Login to AWS

Go to the Amazon Web Services Management Console and log in to your AWS account.

AWS Management Console



Choose Root user or IAM user-

Root User?

The Root User is the main AWS account owner with full access to all AWS resources and account settings. It should be used only for tasks that specifically require root-level access.

IAM User?

An IAM User is a separate AWS identity created for a person or application with specific permissions. It is safer and recommended for everyday AWS activities.


After logging in, you will see the AWS Management Console. 


Step 2 — Open EC2

In the AWS Console:

  1. Click the Search bar at the top.
  2. Type EC2.
  3. Select EC2 from the results.



You will now be inside the EC2 Dashboard.

Step 3 — Choose the AWS Region

At the top-right corner, you will see the current Region.

For example:

  • Mumbai — ap-south-1
  • Singapore — ap-southeast-1
  • US East — us-east-1


For a website serving users in India, Mumbai (ap-south-1) is usually a sensible choice.

Important: EC2 instances are created inside a specific Region. Make sure you remember which Region you used.

Step 4 — Click "Launch Instance"

On the EC2 dashboard:

Instances → Launch instances

You will now see the Launch an instance page.

This is where you tell AWS what kind of virtual computer you want. 


Step 5 — Give Your Instance a Name

Under Name and tags, enter a name.


The name is mainly for your own identification.

Step 6 — Choose an Operating System

Now you need to choose an AMI.

AMI means Amazon Machine Image.

Think of an AMI as:

A ready-made operating system/template for your new server.

You may see options such as:

  • Amazon Linux
  • Ubuntu
  • Windows Server
  • Red Hat
  • Debian

For learning Linux/AWS

I recommend:

Ubuntu Server LTS


Step 7 — Choose Instance Type

Next you'll see Instance type.

This determines the CPU and RAM available to your virtual server.

For example:

t3.micro

or other current eligible instance types.

For learning and small practice workloads, choose a Free Tier-eligible/low-cost option shown by AWS for your account, rather than assuming a particular instance type is free.



Think of it like buying a computer:


For AWS practice, start small.

Step 8 — Create/Login Using a Key Pair

This is a very important step.

AWS needs a secure way for you to log in to your Linux EC2 server.



Under Key pair, choose:

Create new key pair

Give it a name such as: my-aws-key

Choose:

RSA

For Linux/SSH, download the .pem file.

For example: my-aws-key.pem


 

Important warning-

Do not lose this file.

Do not upload it publicly to:

  • GitHub
  • GitLab
  • WhatsApp
  • Public websites

Anyone who obtains your private key may potentially be able to authenticate to your server, depending on your security configuration. 

Step 9 — Configure Network Settings

AWS will now show Network settings.

You will normally see:

  • VPC
  • Subnet
  • Auto-assign Public IP
  • Security Group

For a beginner, AWS's default VPC settings can be used for basic practice.

Network Settings — Key Points

The Network Settings section controls how your EC2 instance connects to the network and how users can access it.

  • VPC: The virtual network where your EC2 instance will be placed.
  • Subnet: A smaller network inside the VPC where the instance is launched.
  • Auto-assign Public IP: Gives the instance a public IP so it can communicate with the internet.
  • Security Group: Acts as a firewall and controls which traffic can reach your EC2 instance.
  • SSH (Port 22): Allows you to remotely connect to a Linux EC2 instance.
  • HTTP (Port 80): Allows normal web traffic to your website.
  • HTTPS (Port 443): Allows secure web traffic to your website.
  • Source — Anywhere (0.0.0.0/0): Allows access from any IPv4 address. Use carefully, especially for SSH.
  • My IP: Restricts access to your current public IP, which is generally safer for SSH during practice.

Easy way to remember

VPC = Network → Subnet = Area → Public IP = Internet → Security Group = Firewall → SSH/HTTP/HTTPS = Access Rules.





Public IP-

If you want to connect to your server from your computer over the internet, make sure the instance has a suitable public IPv4 address.

Step 10 — Configure the Security Group

This is one of the most important concepts in EC2.

A Security Group is like a firewall for your EC2 server.





For example:

Internet
    ↓
Security Group
    ↓
EC2 Server

You may see options such as:

SSH-

Type: SSH
Port: 22

SSH is used to remotely log in to a Linux server.

HTTP-

Type: HTTP
Port: 80

HTTP is used when you want people to access your website.

HTTPS-

Type: HTTPS
Port: 443

HTTPS is used for secure websites.



For basic Linux practice

You can initially allow:

SSH - Port 22

For a web server, you would typically also allow:

HTTP  - Port 80
HTTPS - Port 443

Security recommendation

For SSH, avoid opening port 22 to Anywhere (0.0.0.0/0) unless you have a specific reason.

For learning, you can restrict SSH to My IP when available.

Step 11 — Configure Storage

You will see something like:

Root volume
8 GiB
gp3


This is the disk space of your EC2 server.

For basic practice, the default storage is usually enough.

Think of it like:

Your laptop has a hard disk.
EC2 also needs disk storage.

Step 12 — Review All Settings

Before launching, check:

 


Step 13 — Launch the Instance 

Everything looks good?

Click:

Launch instance

AWS will now create your virtual server.

You should see a message similar to:

Successfully initiated launch of instance


 

Step 14 — Check Your Instance

Go to:

EC2 → Instances → Instances

You should see your instance.

Initially, the status may be: Pending

After a short time it should become: Running

You can also see:

  • Instance ID - i-0daef3fed8dcd588b
  • Instance type- t3.micro
  • Public IPv4 address- 13.233.150.88
  • Private IPv4 address- 172.31.3.72
  • Availability Zone- ap-south-1b
  • Status checks- Initializing   >>   3/3 passed

Step 15 — Get the Public IP Address

Select your EC2 instance.

Look for:

Public IPv4 address

For example:

13.xxx.xxx.xxx

This is the internet-facing address you can use to

connect to your server, provided the networking/security

configuration allows it

Step 16 — Connect to Your EC2 Server

For Ubuntu/Linux, you can connect using SSH.

On Windows, you can use

  • Windows Terminal
  • PowerShell
  • WSL Ubuntu
  • SSH client
Examples-

ssh -i my-aws-key.pem ubuntu@YOUR_PUBLIC_IP

ssh -i my-aws-key.pem ubuntu@13.xxx.xxx.xxx

The exact username depends on the AMI you selected. For Ubuntu, it is commonly:Ubuntu

Step 17 — You Are Inside Your AWS Server

If everything works, you will see something similar to:

ubuntu@ip-172-31-xx-xx:~$

Congratulations! 🎉

You are now controlling a Linux computer running inside AWS.

Try:

pwd

Then:

ls

Then:

whoami

And:

sudo apt update




Step 18 — Stop instance, Reboot instance,

Terminate instance    







No comments:

Post a Comment

Linux vs Windows System Administration Roadmap | Common Skills Guide

 Common Roadmap for Linux & Windows System Administrators Linux System Administration and Windows SystemAdministration have many commo...