Day 05 – Launch Your First EC2 Instance – The Ultimate Guide to Cloud Computing

The CyberSec Guru

Updated on:

First EC2 Instance

If you like this post, then please share it:

Buy me A Coffee!

Support The CyberSec Guru’s Mission

🔐 Fuel the cybersecurity crusade by buying me a coffee! Why your support matters: Zero paywalls: Keep the main content 100% free for learners worldwide, Writeup Access: Get complete in-depth writeup with scripts access within 12 hours of machine drop.

“Your coffee keeps the servers running and the knowledge flowing in our fight against cybercrime.”☕ Support My Work

Buy Me a Coffee Button

Welcome to Day 5 of your AWS 30-Day Roadmap.

If you have been following along, you know the history (Day 1), the core services (Day 2), the console layout (Day 3), and how to store files (Day 4).

Today, things get real.

Today, we are going to launch a virtual computer in the cloud. We are going to log into it. We are going to install a web server on it. And we are going to make it host a website that anyone in the world can visit.

Amazon EC2 (Elastic Compute Cloud) is the heart of AWS. It is the service that started the cloud revolution. It allows you to rent a computer (an “instance”) for pennies an hour, use it to crunch numbers or host a website, and then throw it away when you are done.

In this ultimate guide, we will move beyond the “Next, Next, Finish” tutorials. We are going to dissect every single option in the Launch Wizard—AMIs, Instance Types, Key Pairs, and Security Groups—so you understand exactly what you are building.

The EC2 Anatomy (What makes a Server?)

Before we click “Launch,” you need to understand the four ingredients that make up an EC2 instance. Think of this like buying a custom PC.

1. The AMI (Amazon Machine Image)

  • Analogy: The Operating System disc.
  • What is it? A template that contains the software configuration (Operating System, Application Server, and Applications) required to launch your instance.
  • Common Choices:
    • Amazon Linux 2023: AWS’s own Linux. Lightweight, secure, and free. (We will use this).
    • Ubuntu: The popular developer-friendly Linux.
    • Windows Server: For .NET applications (Costlier due to licensing).

2. The Instance Type (The Hardware)

  • Analogy: The CPU and RAM.
  • What is it? AWS offers hundreds of hardware combinations. They are named with a code like t2.micro or c5.large.
  • The Code Decoded:
    • Family (e.g., ‘t’): Describes the capability (T = General Purpose/Burstable).
    • Generation (e.g., ‘2’): The version number (2 is older than 3).
    • Size (e.g., ‘micro’): The capacity (Nano < Micro < Small < Medium < Large).
  • For Beginners: Always stick to t2.micro or t3.micro. These are “Free Tier Eligible.”

3. The Key Pair (The Key)

  • Analogy: The physical key to your house.
  • What is it? EC2 instances (Linux) generally do not use passwords. They use Cryptography.
  • How it works: You download a private key file (.pem) to your laptop. AWS keeps the public lock. You can only enter the server if you have the .pem file.
  • Warning: If you lose this file, you are locked out forever. There is no “Forgot Password” button.

4. The Security Group (The Firewall)

  • Analogy: The Bouncer at the club door.
  • What is it? A virtual firewall that controls traffic for your instance.
  • Rules: You define rules like “Allow SSH (Port 22) from my IP only” or “Allow HTTP (Port 80) from Anywhere.”
Anatomy of an EC2 Instance
Anatomy of an EC2 Instance

Step-by-Step Lab: Launching Your Web Server

Enough theory. Let’s build.

Goal: Launch a Linux server, install Apache Web Server, and see a “Hello World” page.

Step 1: Open the Wizard

  1. Log into your AWS Console (Day 3).
  2. Ensure you are in N. Virginia (us-east-1).
  3. Search for EC2.
  4. Click the big orange “Launch instance” button.

Step 2: Name and OS

  1. Name: day5-web-server.
  2. Application and OS Images (AMI): Select Amazon Linux.
  3. AMI Dropdown: Ensure “Amazon Linux 2023 AMI” is selected (Free Tier Eligible).

Step 3: Choose Instance Type

  1. Instance Type: Select t2.micro (or t3.micro if t2 is unavailable). Look for the “Free tier eligible” tag.

Step 4: Create a Key Pair

  1. Key pair (login): Click “Create new key pair”.
  2. Key pair name: day5-key.
  3. Key pair type: RSA.
  4. Private key file format:
    • Select .pem (For Mac/Linux or Windows 10+ PowerShell).
    • Select .ppk (Only if you use the old PuTTY software).
  5. Click Create key pair.
  6. Action: The file will download. Do not lose it.

Step 5: Network Settings (The Firewall)

  1. Network Settings: Click “Edit” (Optional, but good to see).
  2. Security Group: Select “Create security group”.
  3. Allow SSH traffic: Check this. Change “Anywhere” to “My IP”. (Security Best Practice!).
  4. Allow HTTP traffic from the internet: CHECK THIS. This opens Port 80 so the world can see your website.

Step 6: Advanced Details (The Magic Script)

This is the “Pro” move. Instead of logging in to install software, we will tell AWS to do it while the server boots.

  1. Scroll all the way down to Advanced details.
  2. Scroll to the bottom field: User data.
  3. Paste this script exactly:
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
echo "<h1>Hello from Day 5! This is my first AWS Server.</h1>" > /var/www/html/index.html
  • What does this do? It updates Linux, installs Apache (httpd), starts the server, and creates a simple HTML homepage.

Step 7: Launch

  1. Click Launch instance.
  2. Wait for the “Success” screen.
  3. Click View all instances.
EC2 Instance Launch Workflow
EC2 Instance Launch Workflow

Connecting to Your Instance

Your server is running (State: Running). But how do you see it?

Method 1: The Web Browser Test

  1. Select your instance in the list.
  2. Look at the bottom details pane. Find Public IPv4 address (e.g., 54.123.45.67).
  3. Copy it.
  4. Open a new browser tab and paste it (ensure it is http:// not https://).
  5. Result: You should see big bold text: “Hello from Day 5! This is my first AWS Server.”
    • Troubleshooting: If it loads forever, check your Security Group. Did you allow HTTP (Port 80)?

Method 2: SSH (The Terminal)

If you want to run commands manually, you need to “SSH” (Secure Shell) into it.

The Easy Way: EC2 Instance Connect

  1. Select your instance.
  2. Click the Connect button (top right).
  3. Select the EC2 Instance Connect tab.
  4. Click Connect.
  5. Result: A browser window opens with a black terminal screen. You are now inside your server! Try typing whoami. It should say ec2-user.
EC2 Webserver
EC2 Webserver

Instance Lifecycle (Stop vs. Terminate)

This is the most expensive mistake beginners make. You need to know the difference between “Stopping” and “Terminating.”

1. Stop Instance

  • Action: Like shutting down your laptop lid.
  • Data: The hard drive (EBS volume) is preserved. Nothing is lost.
  • Billing: You stop paying for the Compute (EC2 hourly rate), BUT you keep paying for the Storage (EBS).
  • IP Address: You lose your Public IP address (it changes when you start again).

2. Terminate Instance

  • Action: Like throwing your laptop into a volcano.
  • Data: The hard drive is deleted (by default). Everything is lost.
  • Billing: You pay $0. Everything is gone.
  • Use Case: When you are done with a lab or experiment.

Rule: For this roadmap, always Terminate your resources at the end of the day unless you plan to use them tomorrow.

Stop vs Terminate Instance
Stop vs Terminate Instance

Elastic IP (The Static Address)

You noticed that when you “Stop” and “Start” an instance, the IP address changes. This is bad for a web server. You want a permanent address.

Elastic IP (EIP) is a static IPv4 address designed for dynamic cloud computing.

  • How to get one: EC2 Dashboard -> Network & Security -> Elastic IPs -> Allocate.
  • How to use it: Action -> Associate Elastic IP -> Select your instance.
  • The Cost Trap:
    • If the EIP is attached to a running instance = FREE.
    • If the EIP is sitting idle (not attached) = YOU PAY HOURLY.
    • Why? Because IPv4 addresses are scarce. AWS punishes you for hoarding them without using them.

EC2 Pricing Models (How to Pay)

On Day 1 we said “Pay-as-you-go,” but there are actually 4 ways to buy EC2.

  1. On-Demand:
    • Pay by the second. No contract. Most flexible. Highest price.
    • Best for: Short-term workloads (like this roadmap).
  2. Reserved Instances (RI):
    • Contract for 1 or 3 years.
    • Discount up to 72%.
    • Best for: Databases or core servers that never turn off.
  3. Savings Plans:
    • Similar to RIs but more flexible (commit to $10/hour rather than specific hardware).
    • Best for: Enterprise steady-state usage.
  4. Spot Instances:
    • Bid on unused AWS capacity.
    • Discount up to 90%.
    • Risk: AWS can terminate your instance with a 2-minute warning if they need the capacity back.
    • Best for: Batch processing, rendering, things that can be interrupted.
On-demand vs Reserve vs Spot Instances
On-demand vs Reserve vs Spot Instances

Conclusion & Cleanup

You did it. You launched a server, hosted a website, and learned how to secure it.

Cleanup Task (Crucial!):

  1. Go to the EC2 Dashboard.
  2. Select your day5-web-server.
  3. Click Instance state -> Terminate instance.
  4. Confirm.
  5. Wait. Ensure the state says Terminated.
  6. Why? Even t2.micro has a monthly limit. If you leave it running for 30 days, you might eat up your Free Tier. Good habits start now.

Tomorrow, on Day 6, we will look at EBS (Elastic Block Store)—the hard drive of the cloud. We will learn how to detach a hard drive from one server and attach it to another.

Server shutdown initiated. See you tomorrow.

Want the Next Part Sooner?

Can’t stand the suspense? Skip the wait! Members unlock the next chapter instantly and get exclusive early access to every future update.

Become a Member

Buy me A Coffee!

Support The CyberSec Guru’s Mission

🔐 Fuel the cybersecurity crusade by buying me a coffee! Your contribution powers free tutorials, hands-on labs, and security resources.

Why your support matters:
  • Writeup Access: Get complete writeup access within 12 hours
  • Zero paywalls: Keep the main content 100% free for learners worldwide

Perks for one-time supporters:
☕️ $5: Shoutout in Buy Me a Coffee
🛡️ $8: Fast-track Access to Live Webinars
💻 $10: Vote on future tutorial topics + exclusive AMA access

“Your coffee keeps the servers running and the knowledge flowing in our fight against cybercrime.”☕ Support My Work

Buy Me a Coffee Button

If you like this post, then please share it:

AWS 101

Discover more from The CyberSec Guru

Subscribe to get the latest posts sent to your email!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from The CyberSec Guru

Subscribe now to keep reading and get access to the full archive.

Continue reading