How I Launched My First AWS EC2 Instance and Secured It with Security Groups (Beginner Friendly Guide)


Cloud computing is one of the core pillars of DevOps, and AWS EC2 is often the starting point. In this guide, I’ll walk you through how I launched my first EC2 instance and set up Security Groups to protect it—step by step!
🧱 What is EC2?
EC2 (Elastic Compute Cloud) is Amazon's virtual machine service. It allows you to run Linux or Windows servers in the cloud.
🛠️ Step 1: Log into AWS and Navigate to EC2
Go to AWS Console
Search for EC2 in the search bar.
Click Launch Instance.
📦 Step 2: Configure Your Instance
Name your instance (e.g.,
my-devops-server
).Choose Amazon Machine Image (AMI) – select Ubuntu 22.04 LTS or Amazon Linux 2 (free tier eligible).
Choose t2.micro (free tier).
Click Next: Configure Instance or scroll down.
🔐 Step 3: Create a New Key Pair (SSH)
Under Key pair (login), select Create new key pair.
Download the
.pem
file and keep it safe—you’ll need this to SSH into the server.
🔒 Step 4: Configure Security Group
A Security Group is like a firewall. It controls which IPs can access your instance via which ports.
Choose Create new security group.
Add the following inbound rules:
SSH (Port 22) → Your IP only (for secure remote access)
HTTP (Port 80) → Anywhere (for web access if hosting a site)
HTTPS (Port 443) → Anywhere (if using SSL)
✅ Pro Tip: Always restrict SSH to your IP for security.
🚀 Step 5: Launch Your Instance
Click Launch Instance.
Wait a few seconds. You’ll see a success message and can go to the Instances tab.
🧑💻 Step 6: Connect to Your EC2 Instance via SSH
On Linux/macOS:
bashCopyEditchmod 400 your-key.pem
ssh -i "your-key.pem" ubuntu@your-public-ip
On Windows: Use PuTTY or Windows Terminal with WSL.
🔍 Bonus: Modify Security Groups Later (If Needed)
Go to EC2 Dashboard > Security Groups.
Select your group and click Edit inbound rules.
Add/remove ports (e.g., open port 3000 for Node.js apps).
🎯 Why This Matters for DevOps
As a DevOps engineer, you'll:
Deploy applications on EC2.
Secure your cloud infrastructure.
Automate provisioning with tools like Terraform or Ansible.
Understanding Security Groups is non-negotiable when working in the cloud.
➡️ If you're following the #90DaysOfDevOps challenge like me, let me know in the comments!
Subscribe to my newsletter
Read articles from Vivek Umrao directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
