Chapter 5: Amazon EC2 (Elastic Compute Cloud)
5.3 How to launch an EC2 instance (console, step by step)
Quick answer: the short, self-contained version of this lesson is the guide How to Launch an EC2 Instance in AWS (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.
चला, आता ॲक्चुअल लॉन्च करूया! कन्सोल उघडा आणि प्रत्येक स्टेप माझ्यासोबत करा – फक्त वाचून EC2 येत नाही. आज आपण Mauli Dairy च्या वेबसाइटसाठी पहिला सर्व्हर web-server-1 लॉन्च करतो.
चलो, अब असली लॉन्च करते हैं! कंसोल खोलो और हर स्टेप मेरे साथ करो – सिर्फ़ पढ़कर EC2 नहीं आता. आज हम Mauli Dairy की वेबसाइट के लिए पहला सर्वर 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 usedcentos)
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.
ध्यान द्या: ही .pem फाइल म्हणजे तुमच्या सर्व्हरची चावी आहे. डाउनलोड झाल्यावर लगेच एका सुरक्षित फोल्डरमध्ये ठेवा – Downloads मध्ये पडून राहिली आणि डिलीट झाली तर AWS ती परत देऊ शकत नाही.
ध्यान दो: यह .pem फ़ाइल आपके सर्वर की चाबी है. डाउनलोड होते ही इसे किसी सुरक्षित फ़ोल्डर में रखो – Downloads में पड़ी रही और डिलीट हो गई तो AWS इसे वापस नहीं दे सकता.
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.
Mauli Dairy चे कस्टमर्स कुठूनही वेबसाइट बघतील, म्हणून 80 आणि 443 Anywhere ला उघडे. पण SSH (22) म्हणजे सर्व्हरच्या आतला दरवाजा – तो फक्त My IP ला. पोर्ट 22 0.0.0.0/0 ला कधीच उघडा ठेवू नका.
Mauli Dairy के कस्टमर्स कहीं से भी वेबसाइट देखेंगे, इसलिए 80 और 443 Anywhere के लिए खुले हैं. लेकिन SSH (22) सर्वर का अंदर वाला दरवाज़ा है – वह सिर्फ़ My IP के लिए. पोर्ट 22 को 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.
या स्क्रिप्टमध्ये sudo नाही, हे लक्षात घ्या – user data पहिल्या बूटला root म्हणून चालतो, म्हणून गरज नाही. पण लॉगिन करून हाताने हेच कमांड्स चालवताना sudo yum install -y nginx आणि sudo service nginx start असा sudo लावायचा.
ध्यान दो, इस स्क्रिप्ट में sudo नहीं है – user data पहले बूट पर root बनकर चलता है, इसलिए ज़रूरत नहीं. लेकिन लॉगिन करके हाथ से यही कमांड्स चलाते समय sudo yum install -y nginx और sudo service nginx start ऐसे sudo लगाना है.
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.
Ravindra Bagale's Tip – मराठी
बरेच students Step 6 मध्ये Auto-assign public IP Disable राहिलं आहे हे बघत नाहीत – मग instance ला public IP नसतो, SSH पण नाही आणि website पण नाही. Launch instance दाबण्याआधी Summary panel मध्ये public IP, web-sg चे तीन rules आणि region Mumbai आहे का हे एकदा नक्की बघा. दोन मिनिटं check केलं तर अर्धा तास debugging वाचतो.
Ravindra Bagale's Tip – हिंदी
बहुत से students Step 6 में Auto-assign public IP Disable रह गया है यह नहीं देखते – फिर instance को public IP नहीं मिलता, न SSH चलता है न website. Launch instance दबाने से पहले Summary panel में public IP, web-sg के तीन rules और region Mumbai है या नहीं, एक बार ज़रूर देखो. दो मिनट check करोगे तो आधा घंटा 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.
समजलं का? AMI + इन्स्टन्स टाइप + की पेअर + सिक्युरिटी ग्रुप + स्टोरेज – हेच लॉन्चचे पाच खांब आहेत. आता पुढे जाऊया सर्व्हरमध्ये लॉगिन करायला.
समझ आया? AMI + इंस्टेंस टाइप + की पेयर + सिक्योरिटी ग्रुप + स्टोरेज – यही लॉन्च के पाँच खंभे हैं. अब आगे चलते हैं सर्वर में लॉगिन करने.