Aws Ec2
1. What is Amazon EC2
Amazon EC2 (Elastic Compute Cloud) is a service that provides virtual machines, called instances.
Think of it as renting a computer in the cloud that you can start, stop, configure, and scale based on your application needs.stalls and
2. Launching an EC2 Instance
Launching an EC2 instance means creating a virtual server. When you hit “Launch Instance,” AWS asks you for a series of choices:
Choose an AMI (operating system)
Choose instance type
Configure storage
Set up security
Assign key pair for login
Select a network
Once you complete these, AWS boots a new server for you in seconds.
3. Amazon Machine Image (AMI)
AMI is a preconfigured template used to launch an instance.
Each AMI contains:
The operating system (Ubuntu, Amazon Linux, Windows etc.)
Default software
Permissions to use the image
Choosing the right AMI is important because it defines how your server will behave from day one.
4. Instance Types
EC2 offers many instance types depending on your use case:
t2.micro / t3.micro for small apps and practice
m5 for general compute
c5 for CPU-heavy workloads
r5 for memory-heavy workloads
p3 / g4 for machine learning and GPU workloads
Instance type decides CPU, RAM, network, and cost.
5. Security Groups
Security Groups act like firewalls for EC2 instances. They control which traffic can enter and leave your server.
Important points:
Inbound rules control what traffic is allowed into the instance
Outbound rules control what traffic is allowed out
Common rules
SSH port 22 for Linux
RDP port 3389 for Windows
HTTP 80 and HTTPS 443 for websites
Security groups are stateful, meaning if traffic comes in, the response can automatically go out.
6. Key Pairs
A key pair is used for secure login.
Public key stays with AWS
Private key (.pem) stays with you
For Linux instances, you use:
ssh -i yourkey.pem ec2-user@public-ip
7. EBS Volumes
EBS (Elastic Block Store) is the disk attached to your EC2 instance. It stores OS files, logs, applications, and data.
Types of volumes:
gp3 general purpose SSD
io1/io2 high performance SSD
st1/sc1 HDD optimized
Key features:
Persistent (data stays even if you stop the instance)
Can be resized anytime
Supports snapshots for backup
8. Elastic IP Address
An Elastic IP (EIP) is a permanent public IP address.
Normally, when you stop/start an instance, the public IP changes.
With an Elastic IP, the IP remains the same forever.
Useful when:
Hosting websites
Connecting to external databases
Running production environments
9. Auto Scaling Basics
Auto Scaling automatically increases or decreases the number of EC2 instances based on real-time demand.
Auto Scaling includes:
Launch Templates that define how new instances should look
Auto Scaling Groups (ASG) that manage instance count
Scaling Policies based on CPU, load, or custom metrics
Benefits:
High availability
Cost optimization
Handles traffic spikes automatically
10. Networking Overview
Every EC2 instance lives inside:
A VPC (your private cloud network)
A Subnet (a segment inside VPC)
A Route Table (defines traffic flow)
Internet Gateway (for internet access)
Instances also get:
Private IP (internal use)
Public IP (internet use)
This networking setup controls how your server communicates inside and outside AWS.
11. When to Use EC2
EC2 is ideal for:
Web hosting
Running APIs
Learning Linux and cloud concepts
Deploying backend servers
Running databases and custom applications
If you need full control over OS, CPU, storage, and networking, EC2 is the right choice.
Conclusion
Amazon EC2 looks complex at first, but once you understand its building blocks, it becomes one of the most flexible tools in AWS.
By learning AMIs, security groups, key pairs, EBS volumes, Elastic IPs, and Auto Scaling, you're already ahead in your cloud journey.
This blog covered everything you need as a beginner to start using EC2 with confidence.