Day 44 — What is EC2 & How to Launch Your First Instance

Today I explored Amazon EC2 (Elastic Compute Cloud) — one of the core services in AWS that allows you to rent virtual servers on-demand. I also learned how to configure an EC2 instance, select the right pricing model, and set up security.


⚙️ What is EC2?

Amazon EC2 provides a web service API for provisioning, managing, and deprovisioning virtual machines (instances) on AWS.

✨ EC2 Features:

  • Virtual servers on-demand (called instances)

  • Easily scale up/down based on demand

  • Pay only for what you use

  • Launch with pre-configured Amazon Machine Images (AMIs)

  • Deep integration with AWS services (S3, IAM, VPC, etc.)


💸 EC2 Pricing Models

  1. On-Demand – Pay by the second/hour, no long-term commitment.

  2. Reserved – Commit for 1 or 3 years to save up to 75%.

  3. Spot – Bid for unused capacity. Cost-effective but instances can be terminated anytime.

  4. Dedicated Hosts – Physical servers allocated to you for regulatory/compliance needs.

📚 Learn more: EC2 Pricing


🧰 EC2 Components

🧱 Amazon Machine Image (AMI)

A template with an OS and preinstalled software. Examples:

  • Amazon Linux 2

  • Ubuntu

  • CentOS

💾 Instance Types

Choose based on your needs (CPU, RAM, storage, network). Examples:

  • t2.micro (free tier eligible)

  • m5.large

  • c6g.xlarge

🏷️ Tags

Key-value pairs that help organize and manage your instances.

  • Example: Environment=Production, Owner=Shaharyar

🔐 Key Pairs

Used for SSH access. AWS uses public–key cryptography. You download the .pem file during instance creation.

🔒 Security Groups

Act as virtual firewalls that control inbound/outbound traffic.

  • Stateful (response traffic is automatically allowed)

  • You can define:

    • Inbound Rules (e.g., allow SSH or HTTP)

    • Outbound Rules (e.g., allow all or restrict egress)


🚀 EC2 Instance Creation — Step by Step

  1. Select AMI (e.g., Amazon Linux 2, Ubuntu, CentOS)

  2. Choose Instance Type (e.g., t2.micro)

  3. Configure Instance Details

  4. Add Storage (default 8 GB — adjust as needed)

  5. Add Tags (for identification)

  6. Configure Security Group

  7. Launch & Download Key Pair

  8. SSH into Instance:

     chmod 400 your-key.pem
     ssh ec2-user@<public-ip> -i your-key.pem
    

🔍 Sample Use Case

Requirement Gathering before instance creation:

  • 🧪 Environment: Dev, QA, Staging, Production

  • 🌐 OS: CentOS

  • 🧠 Size: Minimum (1 vCPU, 1 GB RAM)

  • 💾 Storage: 5GB (sufficient for a lightweight web app)

  • ⚙️ Services: SSH, HTTP, MySQL

  • 👤 Owner/User: DevOps Team

  • 🏷️ Tags: Project=Toolplate, Env=Dev


🧠 What I Learned Today

  • EC2 = virtual machine in the cloud

  • AMIs make launching new instances fast

  • Key pairs and security groups are essential for secure access

  • Proper tagging and sizing ensures easy resource management

Up next: Amazon EBS and understanding snaptshots in it.


0
Subscribe to my newsletter

Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shaharyar Shakir
Shaharyar Shakir