How to Launch Your First AWS EC2 Instance: Step-by-Step Guide

Amazon EC2 (Elastic Compute Cloud) is one of the most foundational services in all of AWS. At its core, EC2 gives you virtual machines — called instances — that run in Amazon's data centers. You choose the operating system, CPU, RAM, and storage. You pay only for what you use. This guide walks you through launching your very first EC2 instance from scratch.

What Is an EC2 Instance?

An EC2 instance is essentially a virtual server hosted on AWS infrastructure. You can use it to host websites, run backend APIs, process batch jobs, or serve as a bastion host for accessing private resources. AWS offers hundreds of instance types optimized for different workloads — compute, memory, storage, and GPU.

Prerequisites

  • An active AWS account (free tier works fine for this guide)
  • Basic familiarity with the AWS Management Console
  • An SSH client (built into macOS/Linux; use PuTTY or Windows Terminal on Windows)

Step 1: Open the EC2 Dashboard

Log into the AWS Management Console, navigate to EC2 under the Services menu, and click Launch Instance. You'll see a multi-step wizard that guides you through each configuration choice.

Step 2: Choose an Amazon Machine Image (AMI)

An AMI is a pre-built template containing the operating system and optionally pre-installed software. For beginners, choose Amazon Linux 2023 — it is free-tier eligible, well-maintained, and comes with the AWS CLI pre-installed.

  • Amazon Linux 2023 — AWS-optimized, great for most workloads
  • Ubuntu 22.04 LTS — Familiar for developers coming from Linux
  • Windows Server — For .NET workloads (note: not free-tier eligible)

Step 3: Choose an Instance Type

The instance type determines your compute resources. For the free tier, select t2.micro or t3.micro (1 vCPU, 1 GB RAM). These are sufficient for learning, small web apps, and development environments.

Step 4: Create a Key Pair

A key pair provides SSH access to your instance. Click Create new key pair, give it a name like my-first-key, choose RSA and .pem format, then download the file. Store it securely — you cannot download it again.

# Set correct permissions on your key file (Linux/macOS)
chmod 400 ~/Downloads/my-first-key.pem

Step 5: Configure Network and Security Group

A security group acts as a virtual firewall. For this tutorial, allow the following inbound rules:

  • SSH (port 22) — from your IP only (not 0.0.0.0/0 in production)
  • HTTP (port 80) — from anywhere, if you plan to host a web server

Step 6: Configure Storage

The default 8 GB gp3 EBS volume is fine for most beginner use cases. Free tier includes up to 30 GB of EBS storage across all your instances.

Step 7: Launch the Instance

Review your settings and click Launch Instance. AWS will spin up your virtual machine within 1–2 minutes. You'll see its Public IPv4 address in the EC2 dashboard once it transitions to the running state.

Step 8: Connect via SSH

Once your instance is running, connect to it using SSH:

# Replace PUBLIC_IP with your instance's actual IP address
ssh -i ~/Downloads/my-first-key.pem ec2-user@PUBLIC_IP

For Ubuntu AMIs, the default user is ubuntu instead of ec2-user.

Step 9: Install a Web Server (Optional)

Once connected, you can immediately install software:

# Update packages
sudo dnf update -y

# Install Apache web server
sudo dnf install -y httpd

# Start and enable Apache
sudo systemctl start httpd
sudo systemctl enable httpd

# Verify it is running
sudo systemctl status httpd

Visit your instance's public IP in a browser — you should see the Apache test page.

Step 10: Stop or Terminate Your Instance

When you're done, always stop or terminate your instance to avoid unexpected charges. Stop preserves your data on the EBS volume but stops billing for compute. Terminate permanently deletes the instance and its root volume.

# Stop an instance using the AWS CLI
aws ec2 stop-instances --instance-ids i-0abcd1234efgh5678

# Terminate an instance
aws ec2 terminate-instances --instance-ids i-0abcd1234efgh5678

Key EC2 Concepts to Remember

  • AMI — The OS template your instance boots from
  • Instance Type — CPU + RAM configuration
  • Security Group — Firewall rules (stateful)
  • Key Pair — SSH authentication credential
  • Elastic IP — A static public IP you can attach to an instance
  • EBS Volume — Persistent block storage attached to your instance

Next Steps

Now that you've launched your first EC2 instance, explore attaching an Elastic IP so your IP doesn't change on restart, setting up IAM roles to give your instance AWS permissions, and using Auto Scaling groups to handle traffic spikes automatically.