How to Launch Your First Virtual Machine (EC2 Instance) on AWS

A Complete DevOps Visual Guide: AMIs, Instance Sizing, Key Pairs, Deep-Dive Security Groups & Multi-Method SSH Connection

⏱️ 14 Min Read 🏷️ AWS EC2 & Security Groups ⚡ Level: Beginner to Pro

Amazon Elastic Compute Cloud (Amazon EC2) is the industry-standard compute engine powering millions of global applications. EC2 provides resizable compute capacity in the cloud, allowing developers and DevOps engineers to deploy virtual servers in under 60 seconds.

In this visual guide, you will learn step-by-step how to launch an EC2 instance, generate secure key pairs, configure Security Group Inbound & Outbound rules, and connect directly using EC2 Instance Connect.

🎯 What You Will Master

  • Navigating the EC2 Console and launching Free Tier instances.
  • Selecting Ubuntu Server 24.04 LTS or Amazon Linux 2023 AMI.
  • Choosing the Free Tier eligible instance type (t2.micro).
  • Configuring a Security Group (SSH Port 22, HTTP Port 80, HTTPS Port 443).
  • Connecting live via 1-click EC2 Instance Connect and terminal SSH.

1. Prerequisites

2. Step-by-Step: Launching Your EC2 Instance

1 Open the EC2 Console & Click "Launch Instance"

  1. Log in to the AWS Management Console and search for EC2 in the top search bar.
  2. On the EC2 Dashboard, click the prominent orange Launch instance button highlighted below.
AWS EC2 Management Console - Launch Instance Dashboard

Figure 1: AWS Management Console — Navigating to EC2 Dashboard and clicking the orange 'Launch instance' button.

2 Configure Name, AMI & Instance Type

  1. Name: Enter devops-web-server-01 in the Name and tags field.
  2. Application and OS Images (AMI): Under Quick Start, select Ubuntu Server 24.04 LTS (HVM) (Free tier eligible).
  3. Instance type: Select t2.micro (1 vCPU, 1 GiB Memory, Free tier eligible).
AWS EC2 Launch Instance - AMI and Instance Type Selection

Figure 2: Setting Instance Name, selecting Ubuntu 24.04 LTS AMI, and choosing the t2.micro Free tier eligible instance type.

3. Key Pair Selection & Security Group Configuration

A Security Group acts as a stateful virtual firewall that controls inbound and outbound network traffic to your EC2 instance.

1 Select Key Pair & Firewall Rules

  1. Key pair (login): Select an existing key (e.g. my-devops-key.pem) or click Create new key pair.
  2. Network settings: Select Create security group and tick:
    • ☑️ Allow SSH traffic from: My IP (Restricts terminal access to your IP address)
    • ☑️ Allow HTTPS traffic from the internet (Port 443)
    • ☑️ Allow HTTP traffic from the internet (Port 80)
  3. Click the orange Launch instance button on the right-side summary panel.
AWS EC2 Key Pair and Security Group Inbound Rules

Figure 3: Configuring Key Pair (.pem) and Security Group Inbound Firewall rules (SSH Port 22, HTTP Port 80, HTTPS Port 443).

Type Protocol Port Range Source (CIDR) Security Recommendation
SSH TCP 22 My IP / 32 Restrict to My IP to prevent unauthorized brute-force attempts.
HTTP TCP 80 0.0.0.0/0 Allows standard public web traffic to reach your web server.
HTTPS TCP 443 0.0.0.0/0 Allows encrypted SSL/TLS web traffic.
Custom TCP TCP 8080 / 3000 0.0.0.0/0 For Node.js, Spring Boot, Jenkins, or Docker container applications.

4. Viewing Running Instance & Connecting

1 View Running Instance

Navigate to EC2 > Instances. Select your instance devops-web-server-01. Check that Instance state displays ✔ Running with 2/2 status checks passed, and note your assigned Public IPv4 address (e.g. 54.210.88.142).

Click the highlighted Connect button at the top.

AWS EC2 Instances List Running State and Connect Button

Figure 4: EC2 Instances Dashboard displaying Running state, 2/2 status checks passed, Public IP, and the Connect button.

2 Connect via EC2 Instance Connect (In-Browser Shell)

In the Connect to instance modal, select the EC2 Instance Connect tab, confirm the username (ubuntu), and click the orange Connect button to launch a live browser shell directly inside AWS!

AWS EC2 Instance Connect Dialog and Live Terminal

Figure 5: 1-Click EC2 Instance Connect — Connecting directly to the Linux terminal in your browser.

# Or connect using terminal SSH from your computer:
# 1. Set key permissions
chmod 400 my-devops-key.pem

# 2. SSH into your Ubuntu EC2 instance
ssh -i "my-devops-key.pem" ubuntu@<YOUR-EC2-PUBLIC-IP>

5. Stopping or Terminating Idle Instances

🛑 Prevent Unexpected AWS Charges

  • Stop Instance: Pauses compute billing while keeping your EBS volume data intact. Select Instance > Instance state > Stop instance.
  • Terminate Instance: Permanently deletes the instance and attached storage volume when your lab practice is finished.

🎉 AWS EC2 Mastery Complete!

You now know how to provision EC2 instances, configure high-security inbound firewall rules, connect smoothly via EC2 Instance Connect, and manage instance lifecycle states.