🚀 AWS EC2 Instance Setup & Deployment Guide
A step-by-step beginner-friendly guide for Cloud Engineers
📘 Project Overview
This project demonstrates how to launch, configure, and manage EC2 instances on AWS. You’ll learn how to deploy applications, manage SSH access, and automate cloud setup.
🎯 Project Objectives
- Launch an EC2 instance using AWS Console.
- Configure SSH access using key pairs.
- Install software (Apache, Nginx, Python, Node.js).
- Deploy a sample web app.
- Secure EC2 using Security Groups.
- Automate setup using User Data scripts.
🧰 Tools & Technologies Used
| Category | Tools / Services |
|---|---|
| Cloud Platform | AWS (Amazon Web Services) |
| Compute | EC2 (Elastic Compute Cloud) |
| Operating System | Ubuntu / Amazon Linux |
| Networking | VPC, Subnets, Security Groups, Elastic IP |
| Storage | EBS (Elastic Block Store) |
| Monitoring | CloudWatch |
| Automation | User Data / Shell Scripts |
| Access | SSH (.pem key) |
⚙️ Step-by-Step Setup
1️⃣ Launch EC2 Instance
- Go to AWS Console → EC2 → Launch Instance.
- Select AMI: Ubuntu 22.04 LTS or Amazon Linux 2.
- Choose Instance Type:
t2.micro. - Create/select a Key Pair for SSH.
- Configure Security Groups (allow SSH, HTTP, HTTPS).
- Launch your instance 🎉
2️⃣ Connect to EC2
chmod 400 your-key.pem
ssh -i your-key.pem ubuntu@<EC2-Public-IP>
3️⃣ Install Web Server
sudo apt update -y
sudo apt install apache2 -y
sudo systemctl start apache2
sudo systemctl enable apache2
Access in browser: http://<EC2-Public-IP>
4️⃣ Deploy Your App
sudo apt install git -y
git clone https://github.com/username/repo.git
cd repo
5️⃣ Security Best Practices
- Use Security Groups wisely.
- Apply IAM roles for limited permissions.
- Enable HTTPS with AWS Certificate Manager.
6️⃣ Stop / Start / Terminate
- Stop: Data preserved.
- Terminate: Instance deleted.
🧩 EC2 User Data Example
#!/bin/bash
sudo apt update -y
sudo apt install apache2 -y
sudo systemctl start apache2
echo "Hello from EC2 User Data Script" > /var/www/html/index.html
📊 Monitoring & Optimization
- Use CloudWatch to monitor metrics.
- Auto Scaling Groups for load handling.
- Assign Elastic IP for fixed access.
- Take EBS Snapshots for backup.
📋 Interview Questions
- What is EC2 and its purpose?
- Difference between Stop and Terminate?
- What are key pairs?
- How to secure EC2?
- Explain Elastic IP and its use.
🧾 Conclusion
This blog covers complete AWS EC2 setup — from launching instances to deploying secure web applications. A must-know for AWS & DevOps engineers!
🌐 Author
👤 Mahesh Sanjay Shelke
AWS & Linux Enthusiast | Cloud Engineer
📧 msshelke0505@gmail.com
