AWS Builder Center
Getting Started with Amazon EC2: Launching Your First Cloud Server

Getting Started with Amazon EC2: Launching Your First Cloud Server

Learn how to launch your first Amazon EC2 instance from scratch — covering AMI selection, instance types, security groups, SSH access, and cost optimization tips. A practical, beginner-friendly guide written for developers taking their first steps into AWS cloud computing.

Getting Started with Amazon EC2: Launching Your First Cloud Server

If you've been hearing terms like "cloud server," "virtual machine," or "EC2 instance" and wondering what they actually mean in practice — this guide is for you. By the end of this article, you'll have a clear understanding of Amazon EC2, and you'll know exactly how to launch, connect to, and manage your first cloud server on AWS.
Let's get started.

What Is Amazon EC2?

Amazon Elastic Compute Cloud (EC2) is one of the core services of AWS. It provides resizable, on-demand virtual servers — called instances — that run in the cloud. Instead of buying and managing physical hardware, you simply rent computing capacity from AWS and pay only for what you use.
Think of EC2 like renting an apartment instead of buying a house. You get all the functionality you need, you can scale up or downsize whenever you want, and you only pay for the time you actually use it.
EC2 instances can run virtually any workload — from hosting a personal website, to running a backend API, to training machine learning models.

Why Is EC2 Important?

Before cloud computing, developers had to provision physical servers — a process that could take days or weeks and cost thousands of dollars upfront. Amazon EC2 changed everything by offering:
  • On-demand provisioning — Launch a server in under 60 seconds
  • Global availability — Deploy your application across 30+ AWS Regions worldwide
  • Flexible pricing — Pay-as-you-go, Reserved, Spot, and Savings Plans options
  • Scalability — Scale from 1 instance to thousands based on traffic
  • Security — Built-in integration with AWS IAM, VPC, and Security Groups
  • Wide OS support — Amazon Linux, Ubuntu, Windows Server, Red Hat, and more
For a BTech student or early-career developer, EC2 is the single most important AWS service to understand — because almost every real-world application eventually runs on compute.

Core Concepts Before You Launch

Before clicking "Launch Instance," let's understand three foundational concepts:

1. Amazon Machine Image (AMI)

An AMI is a pre-configured template that contains the operating system, software, and configuration needed to launch your instance. Think of it as a snapshot or blueprint for your server.
Common choices:
  • Amazon Linux 2023 — Lightweight, AWS-optimized, great for beginners
  • Ubuntu Server 22.04 LTS — Popular in the developer community
  • Windows Server — For .NET or Windows-based workloads

2. Instance Types

Instance types define the hardware profile of your virtual server — CPU, memory, storage, and networking. AWS organizes them into families:
FamilyOptimized ForExample
t3, t4gGeneral purpose (burstable)Web servers, dev/test
m6i, m7gBalanced compute/memoryApplication servers
c6i, c7gCompute-intensiveBatch processing, ML inference
r6i, r7gMemory-intensiveIn-memory databases
For beginners, t2.micro or t3.micro is the perfect starting point. It's free-tier eligible and handles most learning workloads easily.

3. Security Groups

A Security Group acts as a virtual firewall for your EC2 instance. It controls what traffic is allowed in (inbound) and out (outbound).
Key rules to know:
  • Port 22 (SSH) — Required to connect to Linux instances
  • Port 80 (HTTP) — For web traffic
  • Port 443 (HTTPS) — For secure web traffic
  • Port 3389 (RDP) — For Windows Remote Desktop
⚠️ Security tip: Never open port 22 to 0.0.0.0/0 (all IPs) in a production environment. Always restrict SSH access to your specific IP address.

Step-by-Step: Launching Your First EC2 Instance

Prerequisites

  • An AWS account (free tier works perfectly)
  • A web browser
  • Approximately 10 minutes

Step 1: Open the EC2 Console

  1. Log in to the AWS Management Console 
  2. In the search bar at the top, type EC2 and click on it
  3. In the EC2 Dashboard, click "Launch Instance"

Step 2: Name Your Instance

Give your instance a meaningful name. For this tutorial, use:
1
my-first-ec2-server

Step 3: Choose an Amazon Machine Image (AMI)

Under "Application and OS Images", select:
  • Amazon Linux 2023 AMI (Free tier eligible)
  • Architecture: 64-bit (x86)
This is the recommended option for beginners — it's fast, lightweight, and well-documented.

Step 4: Choose an Instance Type

Under "Instance Type", select:
1
t2.micro (1 vCPU, 1 GiB RAM) — Free Tier Eligible
This is more than enough to host a simple web application or experiment with the Linux command line.

Step 5: Create a Key Pair (Critical!)

A key pair is how you securely connect to your instance via SSH. AWS uses asymmetric encryption — AWS holds the public key, and you download the private key.
  1. Click "Create new key pair"
  2. Name it: my-ec2-key
  3. Key pair type: RSA
  4. Private key file format: .pem (for Mac/Linux) or .ppk (for Windows with PuTTY)
  5. Click "Create key pair" — the .pem file will download automatically
⚠️ Store this file safely! You cannot download it again. If you lose it, you'll be locked out of your instance.
Set the correct permissions on your key file:
bash
1
chmod 400 my-ec2-key.pem

Step 6: Configure Network Settings (Security Group)

  1. Under "Network Settings", click "Edit"
  2. Keep the default VPC selected
  3. For "Firewall (Security Groups)", choose "Create security group"
  4. Add the following inbound rules:
TypeProtocolPortSource
SSHTCP22My IP
HTTPTCP80Anywhere (0.0.0.0/0)

Step 7: Configure Storage

The default 8 GiB gp3 volume is sufficient for learning purposes. You can increase this later without stopping the instance.

Step 8: Review and Launch

  1. Review the Summary panel on the right
  2. Verify: AMI, instance type, key pair, and security group
  3. Click "Launch Instance"
Your instance will move through these states:
1
pending → running
This typically takes 30–60 seconds. Once the status shows "2/2 checks passed", your server is ready.

Connecting to Your Instance via SSH

Once your instance is running, navigate to the EC2 Instances list, select your instance, and click "Connect" for the exact SSH command. It will look like this:
bash
1
ssh -i "my-ec2-key.pem" ec2-user@<your-public-ip-address>
Replace <your-public-ip-address> with the Public IPv4 address shown in the instance details panel.
On Windows, you can use:
  • Windows Terminal or PowerShell (modern Windows supports SSH natively)
  • PuTTY (use the .ppk key format)
  • AWS CloudShell (browser-based, no local setup needed)
Once connected, you'll see the Amazon Linux prompt:
bash
1
[ec2-user@ip-172-31-xx-xx ~]$
You now have a fully functional cloud server. You can install software, run scripts, and build applications.
bash
1
2
3
4
5
6
7
8
9
10
11
12
# Update the package manager
sudo yum update -y

# Install the Apache web server
sudo yum install httpd -y

# Start Apache
sudo systemctl start httpd
sudo systemctl enable httpd

# Confirm it's running
sudo systemctl status httpd
Now open your browser and navigate to your instance's Public IP on port 80 — you'll see the Apache test page. You just deployed your first web server on the cloud! 🎉

Stopping vs. Terminating: Know the Difference

This is one of the most important distinctions for beginners — and one of the most common sources of accidental data loss.
ActionWhat HappensBilling Impact
StopInstance is powered off. Data on EBS volumes is retained.EC2 compute charges stop. EBS storage charges continue.
RebootInstance restarts. Data and IP address are preserved.Billing continues normally.
TerminateInstance is permanently deleted. EBS root volume is deleted by default.All charges stop immediately.
💡 Rule of thumb: Use Stop when you want to pause your server temporarily (overnight, on weekends). Use Terminate only when you are done with the instance forever.

Cost Optimization Tips for Beginners

AWS billing can surprise newcomers. Here are practical strategies to keep costs under control:
1. Use the Free Tier New AWS accounts get 750 hours/month of t2.micro or t3.micro for the first 12 months — that's enough for one instance running 24/7.
2. Stop Instances When Not in Use A stopped EC2 instance does not incur compute charges. Set a habit: stop your dev/test instances at the end of each session.
3. Set Up a Billing Alert
  • Go to AWS Billing Console → Budgets
  • Create a budget for $5/month
  • AWS will email you before you exceed it
4. Use Spot Instances for Non-Critical Workloads Spot Instances can save up to 90% compared to On-Demand pricing. They are ideal for batch jobs, testing, and fault-tolerant workloads.
5. Right-Size Your Instances Don't run a c5.4xlarge for a personal blog. Use AWS Cost Explorer and AWS Compute Optimizer to identify over-provisioned instances.
6. Elastic IPs Have Costs Too An Elastic IP (static public IP) is free when attached to a running instance — but if it's allocated but not attached, AWS charges you. Release Elastic IPs you're not using.

Common Mistakes Beginners Make

Learning from mistakes (especially other people's mistakes) is one of the fastest ways to improve. Here are the most common EC2 pitfalls:
❌ Losing the .pem key file There is no recovery path. Always back up your key pair file in a secure location immediately after download.
❌ Opening port 22 to all IPs Bots actively scan the internet for open SSH ports. Restrict SSH access to your specific IP address only.
❌ Forgetting to stop/terminate unused instances Instances left running accumulate costs. Even a single t3.medium left running accidentally can cost $30–50/month.
❌ Confusing Stop with Terminate Terminating is permanent. Always double-check before terminating an instance that holds important data.
❌ Using the root AWS account for daily work Never use your AWS root account for day-to-day tasks. Create an IAM user with appropriate permissions and use that instead. Enable MFA on your root account immediately.
❌ Not tagging resources Tags like Name, Environment, and Project help you organize resources and track costs. Make tagging a habit from day one.

What to Learn Next

Now that you've launched your first EC2 instance, here's a suggested learning path:
  1. Elastic Load Balancing (ELB) — Distribute traffic across multiple instances
  2. Auto Scaling Groups — Automatically scale your fleet based on demand
  3. Amazon EBS — Block storage for persistent data
  4. Amazon VPC — Build private, isolated network environments
  5. AWS Systems Manager — Manage instances without SSH
  6. AWS CloudWatch — Monitor CPU, memory, and set alarms
Each of these services builds on your EC2 knowledge and forms the backbone of production-grade AWS architectures.

Conclusion

Amazon EC2 is the foundation of cloud computing on AWS — and now you've taken your first real step into that world. You've learned what EC2 is, why it matters, how to choose the right AMI and instance type, how to configure security groups, how to connect via SSH, and how to manage your instance responsibly.
The cloud is not intimidating once you start building. Every complex architecture you see in AWS documentation started with a single EC2 instance, much like the one you just launched.
Keep experimenting, keep building, and don't forget to stop your instances when you're done. ☁️
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article