Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 5: Amazon EC2 (Elastic Compute Cloud)

5.3 How to launch an EC2 instance (console, step by step)

Come on, let's do the actual launch now! Open the console and do every step along with me – you cannot learn EC2 just by reading. Today we launch the first server for Mauli Dairy's website, web-server-1.

Before you start: sign in to the AWS Management Console, and select the Mumbai (ap-south-1) region from the top-right region menu.

Step 1 — Open EC2. Search "EC2" in the top search bar → EC2 Dashboard → Launch instance.

Step 2 — Name and tags. Name: web-server-1. (This creates a tag Name=web-server-1.)

Step 3 — Choose an AMI. Under Application and OS Images choose one of:

  • Amazon Linux 2023 AMI (default, free-tier eligible) — user ec2-user
  • Ubuntu Server 24.04 LTS (or 22.04 LTS) — user ubuntu
  • CentOS Stream 9 — search Browse more AMIs → AWS Marketplace / Community AMIs for the official "CentOS Stream 9" image — user ec2-user (older CentOS images used centos)

Keep architecture 64-bit (x86) unless you chose a Graviton type.

Step 4 — Instance type. Choose a free-tier eligible type such as t3.micro or t2.micro (label shown in the list).

Step 5 — Key pair (login). Click Create new key pair → name mykey → type RSA or ED25519 → format .pem (for OpenSSH on Linux/Mac/Windows 10+) or .ppk (for PuTTY) → Create. The file downloads only once — keep it safe.

Pay attention: this .pem file is the key to your server. As soon as it downloads, put it in a safe folder – if it lies in Downloads and gets deleted, AWS cannot give it back.

Step 6 — Network settings. Click Edit:

  • VPC: default VPC; Subnet: No preference (or pick an AZ)
  • Auto-assign public IP: Enable
  • Firewall (security groups): Create security group, name web-sg, with inbound rules:
Type Protocol Port Source Why
SSH TCP 22 My IP (e.g. 49.36.12.7/32) Only you can log in
HTTP TCP 80 Anywhere-IPv4 0.0.0.0/0 Website
HTTPS TCP 443 Anywhere-IPv4 0.0.0.0/0 Secure website

Mauli Dairy's customers will open the website from anywhere, so 80 and 443 are open to Anywhere. But SSH (22) is the inner door of the server – it is only for My IP. Never leave port 22 open to 0.0.0.0/0.

Step 7 — Configure storage. Default root volume 8 GiB gp3 (Ubuntu defaults to 8 GiB; you can set up to 30 GiB within typical free-tier storage limits).

Step 8 — Advanced details (optional). Paste a User data script to auto-install a web server at first boot, for example on Amazon Linux 2023:

#!/bin/bash
yum install -y nginx
echo "<h1>Hello from $(hostname -f)</h1>" > /usr/share/nginx/html/index.html
service nginx start
systemctl enable nginx

Notice that this script has no sudo – user data runs as root at first boot, so it is not needed. But when you log in and run the same commands by hand, add sudo, like sudo yum install -y nginx and sudo service nginx start.

Step 9 — Launch. Review the Summary panel → Launch instance → View all instances. Wait until Instance state = Running and Status checks = 2/2 checks passed. Copy the Public IPv4 address.

Step 10 — Test. If you used the user-data script, open http://<PUBLIC_IP> in a browser (note: http, not https).

The browser shows a timeout?

Almost always one of: (1) security group does not allow port 80 from 0.0.0.0/0, (2) you typed https:// but no TLS is configured, (3) the web server is not running, (4) instance is in a subnet without a route to an Internet Gateway, or (5) no public IP assigned.

Ravindra Bagale's Tip

Many students don't notice that Auto-assign public IP is still Disable in Step 6 – then the instance has no public IP, so no SSH and no website. Before you press Launch instance, check once in the Summary panel that the public IP, the three web-sg rules and the Mumbai region are there. Two minutes of checking saves half an hour of debugging.

Lab

Chala, Mauli Dairy sathi mauli-web-1 naavacha Amazon Linux 2023 t3.micro Mumbai madhe launch kara – web-sg sobat (22 My IP, 80 aani 443 Anywhere) aani Step 8 cha user data paste karun. Status checks = 2/2 aalyavar http://<PUBLIC_IP> ughda aani "Hello from ..." page disla ka te bagha. Page nahi disla tar varchya warning box madhla pratyek point kramane check kara.

Got it? AMI + instance type + key pair + security group + storage – these are the five pillars of a launch. Now let's move on to logging in to the server.