Skip to content

Latest commit

 

History

History
269 lines (155 loc) · 6.24 KB

File metadata and controls

269 lines (155 loc) · 6.24 KB

🛠️ Step-by-Step Implementation Guide

This guide helps you deploy a scalable and fault-tolerant web application on AWS using a custom VPC, EC2 instances, and an Application Load Balancer (ALB). Ideal for hands-on learners and beginners in AWS networking.

✅ Step 1: Create a Custom VPC

Go to the VPC Dashboard → click Create VPC

Choose the "VPC only" option

Enter the following:

Name tag: MyVPC

IPv4 CIDR block: 10.0.0.0/16

Leave rest as default

AWS will automatically create:

Two public subnets (in different AZs)

A Route Table

An Internet Gateway (attached to the VPC)

Leave VPC Endpoints unchecked or hidden

image image image image

🖥️ Step 2: Launch EC2 Instances (Web Servers)

Repeat this process for:

Server-1

Server-2

Server-3

Configuration:

Go to EC2 Dashboard → Launch Instance

Use:

AMI: Amazon Linux 2 or Ubuntu

Instance Type: t2.micro

image image

In Network Settings:

VPC: MyVPC

Subnet: One of the public subnets

Enable Auto-assign Public IP

In Advanced → User data, paste:

#!/bin/bash
apt-get update
apt-get install nginx -y

cat <<EOF > /var/www/html/index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>Welcome to $(hostname)</title>
  <style>
    body {
      background: linear-gradient(135deg, #1e3c72, #2a5298);
      color: white;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      height: 100vh;
      margin: 0;
    }
    h1 {
      font-size: 3em;
      margin: 0.2em 0;
    }
    p {
      font-size: 1.2em;
      color: #cce3ff;
    }
    .hostname {
      background: #ffffff33;
      padding: 0.5em 1em;
      border-radius: 10px;
      font-weight: bold;
    }
  </style>
</head>
<body>
  <h1> Welcome to Your Server!</h1>
  <p>This server is proudly hosted as:</p>
  <div class="hostname">$(hostname)</div>
</body>
</html>
EOF
image image

In Security Group, allow:

✅ HTTP (port 80) – for web access

✅ (Optional) SSH (port 22) – for terminal access

image

🎯 Step 3: Create Target Group

Go to EC2 → Target Groups

Click Create target group

Set:

Name: TG-1

Target type: Instance

Protocol: HTTP, Port: 80

VPC: MyVPC

After creating, click Register targets

Select all 3 EC2 instances and add them

image

⚖️ Step 4: Create Application Load Balancer (ALB)

Go to Load Balancers → click Create Load Balancer

Choose Application Load Balancer

Configure:

Name: MyALB

Scheme: Internet-facing

Listeners: HTTP (port 80)

Choose both public subnets created with MyVPC (in different AZs)

Select or create a Security Group that allows:

✅ HTTP (port 80)

In Listener configuration, forward traffic to Target Group: TG-1

image image image image

🌐 Step 5: Test Load Balancer

Go to EC2 → Load Balancers

Click your ALB to open details

Copy the DNS name, something like:

myalb-123456789.ap-south-1.elb.amazonaws.com

Paste it into a browser like:

Refresh the page multiple times. You should see different outputs like:

Welcome from Server-1 at 13.232.XXX.XX Welcome from Server-2 at 13.232.XXX.XX Welcome from Server-3 at 13.232.XXX.XX

image image image

📌 Recap of Resources

Resource

Description

VPC

Custom isolated network (MyVPC)

Subnets

Two public subnets across different AZs

EC2 Instances

3 NGINX web servers with dynamic IP responses

Security Group

Allows HTTP access on port 80

Target Group

Attached EC2 instances for routing

ALB

Internet-facing load balancer

🚀 What's Next?

Here’s how you can expand this setup:

🔄 Add Auto Scaling to dynamically scale EC2 instances

📊 Monitor using CloudWatch for metrics & logs

🔐 Enable HTTPS with SSL from AWS Certificate Manager (ACM)

🛡️ Add Private Subnets for databases or internal services

🌍 Use Route 53 to link a custom domain

🧱 Automate with Terraform or CloudFormation

📚 References

📁 Read project-details.md for architecture concepts

📽️ Watch walkthrough in recording.mp4 (if available)

🙋 Contributors

👨‍💻 Author: Arsh Chauhan🎓 Mentor: Omkar Sharma