🚀 AWS EC2 Instance Setup & Deployment Guide

AWS EC2 Instance Setup & Deployment Guide - Mahesh Shelke

🚀 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

CategoryTools / Services
Cloud PlatformAWS (Amazon Web Services)
ComputeEC2 (Elastic Compute Cloud)
Operating SystemUbuntu / Amazon Linux
NetworkingVPC, Subnets, Security Groups, Elastic IP
StorageEBS (Elastic Block Store)
MonitoringCloudWatch
AutomationUser Data / Shell Scripts
AccessSSH (.pem key)

⚙️ Step-by-Step Setup

1️⃣ Launch EC2 Instance

  1. Go to AWS Console → EC2 → Launch Instance.
  2. Select AMI: Ubuntu 22.04 LTS or Amazon Linux 2.
  3. Choose Instance Type: t2.micro.
  4. Create/select a Key Pair for SSH.
  5. Configure Security Groups (allow SSH, HTTP, HTTPS).
  6. 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