Deploy the Landmark Technologies web page on EC2 instances behind an Application Load Balancer with Auto Scaling and a custom domain name.
In a real production environment, you never run a single server. If that server dies, your application goes down. Instead, we set up:
- Multiple EC2 instances running the same application — so if one dies, others handle traffic
- An Application Load Balancer (ALB) — sits in front of all instances and distributes traffic evenly. Users hit ONE URL and the ALB decides which server handles the request
- An Auto Scaling Group (ASG) — automatically adds more servers when traffic is high and removes them when traffic is low. Also replaces crashed servers automatically
- A custom domain name — so users access
www.mylandmarktech.cominstead of an ugly AWS DNS name
Without ALB + ASG: With ALB + ASG:
┌────────┐ ┌──────┐ ┌────────┐ ┌─────┐ ┌──────┐
│ User │────▶│ EC2 │ │ User │────▶│ ALB │────▶│ EC2 │
└────────┘ └──────┘ └────────┘ │ │ ├──────┤
│ │────▶│ EC2 │
• Single point of failure │ │ ├──────┤
• Can't handle traffic spikes │ │────▶│ EC2 │
• If server dies = app is DOWN └─────┘ └──────┘
• High availability
• Auto-scales with traffic
• Self-heals (replaces dead servers)
• Users see ONE URL
| Component | Role | Analogy |
|---|---|---|
| Launch Template | Blueprint for each server (what AMI, instance type, startup script) | A recipe for baking identical cakes |
| Auto Scaling Group | Manages the fleet of servers (launches, monitors, replaces) | A manager who hires/fires workers based on workload |
| Target Group | Registry of healthy servers the ALB can send traffic to | A list of available workers |
| ALB | Receives all traffic and distributes across healthy servers | A receptionist directing customers to available agents |
| Route 53 | Maps your domain name to the ALB | A phone book entry for your business |
User types: www.mylandmarktech.com
│
▼
Route 53 resolves domain → ALB IP address
│
▼
ALB receives request → checks Target Group for healthy instances
│
▼
ALB forwards to one healthy EC2 instance (round-robin)
│
▼
EC2 serves the Landmark Technologies web page
│
▼
User sees the page (with that specific server's IP in the content)
When you refresh the page, the ALB may send you to a DIFFERENT server — you'll see a different Host IP, proving load balancing is working.
┌──────────────┐ ┌─────────────────────┐ ┌──────────────────────┐
│ Route 53 │────────▶│ Application Load │────────▶│ Auto Scaling Group │
│ (domain) │ │ Balancer (ALB) │ │ │
└──────────────┘ └─────────────────────┘ │ ┌──────┐ ┌──────┐ │
│ │ EC2 │ │ EC2 │ │
│ │ #1 │ │ #2 │ │
│ └──────┘ └──────┘ │
└──────────────────────┘
- AWS account
- A VPC with at least 2 public subnets in different AZs
- (Optional) A registered domain name for Route 53
The Launch Template defines what each EC2 instance looks like.
- Go to EC2 → Launch Templates → Create launch template
- Fill in:
| Field | Value |
|---|---|
| Template name | landmark-lt |
| AMI | Amazon Linux 2023 |
| Instance type | t2.micro |
| Key pair | Select your key pair |
| Security group | Create new: allow HTTP (80) from anywhere and SSH (22) from your IP |
| Advanced Details → User data | Paste the script from alb-demo file below |
#!/bin/bash
yum update -y
yum install -y httpd
systemctl start httpd
systemctl enable httpd
HOST_IP=$(hostname -f)
CURRENT_DATE=$(date '+%Y-%m-%d %H:%M:%S')
cat > /var/www/html/index.html <<EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Landmark Technologies</title>
<style>
body { background-color: #1a1a2e; text-align: center; font-family: Arial; color: #fff; }
h1 { color: #00d4ff; font-size: 36px; }
h2 { color: #00d4ff; font-size: 22px; }
.content { background: #16213e; margin: 40px auto; padding: 40px; border-radius: 12px; width: 80%; max-width: 700px; }
</style>
</head>
<body>
<div class="content">
<h1>Welcome to Landmark Technologies</h1>
<h2>Online DevOps & AI Training Platform</h2>
<p><strong>Host:</strong> $HOST_IP</p>
<p><strong>Deployed:</strong> $CURRENT_DATE</p>
<p>Courses: DevOps Engineering | AI & Machine Learning | Cloud Computing | Kubernetes</p>
<p>Email: info@mylandmarktech.com | Phone: +1 437 215 2483</p>
</div>
</body>
</html>
EOF
systemctl restart httpd- Click Create launch template
The Target Group is where the ALB sends traffic.
- Go to EC2 → Target Groups → Create target group
- Fill in:
| Field | Value |
|---|---|
| Target type | Instances |
| Target group name | landmark-tg |
| Protocol | HTTP |
| Port | 80 |
| VPC | Your VPC |
| Health check path | / |
| Healthy threshold | 2 |
| Interval | 30 seconds |
- Click Next → Do NOT register targets yet (ASG will do it automatically)
- Click Create target group
- Go to EC2 → Load Balancers → Create Load Balancer → Application Load Balancer
- Fill in:
| Field | Value |
|---|---|
| Name | landmark-alb |
| Scheme | Internet-facing |
| IP address type | IPv4 |
| VPC | Your VPC |
| Mappings | Select at least 2 public subnets in different AZs |
| Security group | Create new: allow HTTP (80) from anywhere (and 443 if using HTTPS) |
| Listener | HTTP : 80 → Forward to landmark-tg |
- Click Create load balancer
- Wait for state to become Active
The ASG automatically launches and manages EC2 instances.
- Go to EC2 → Auto Scaling Groups → Create Auto Scaling group
- Fill in:
Step 1 — Choose launch template:
| Field | Value |
|---|---|
| Name | landmark-asg |
| Launch template | landmark-lt |
Step 2 — Choose instance launch options:
| Field | Value |
|---|---|
| VPC | Your VPC |
| Availability Zones | Select the same subnets as the ALB |
Step 3 — Configure advanced options:
| Field | Value |
|---|---|
| Load balancing | ✅ Attach to an existing load balancer |
| Choose target group | landmark-tg |
| Health check type | ELB |
| Health check grace period | 300 seconds |
Step 4 — Configure group size and scaling:
| Field | Value |
|---|---|
| Desired capacity | 2 |
| Minimum capacity | 2 |
| Maximum capacity | 4 |
| Scaling policy | Target tracking → Average CPU → 50% |
Step 5 — Add tags:
| Key | Value |
|---|---|
| Name | landmark-web-server |
- Click Create Auto Scaling group
The ASG will launch 2 instances and register them with the Target Group automatically.
- Go to EC2 → Target Groups → landmark-tg → Targets
- Wait until instances show healthy
- Go to EC2 → Load Balancers → landmark-alb
- Copy the DNS name (e.g.,
landmark-alb-123456789.us-east-1.elb.amazonaws.com) - Open in browser:
http://<alb-dns-name> - Refresh multiple times — you should see different Host IPs (traffic distributed between instances)
Terminate one instance manually:
- Go to EC2 → Instances → select one landmark instance → Terminate
- Watch the ASG launch a replacement automatically (check ASG → Activity tab)
Option A: Register a new domain in Route 53
- Go to Route 53 → Registered domains → Register domain
- Search for your domain (e.g.,
mylandmarktech.com) - Complete the registration (takes 10-30 minutes)
Option B: Use an existing domain (transfer nameservers)
- Go to Route 53 → Hosted zones → Create hosted zone
- Domain name:
mylandmarktech.com - Type: Public hosted zone
- Copy the 4 NS records from Route 53
- Update your domain registrar's nameservers to these values
- Go to Route 53 → Hosted zones → your domain → Create record
- Fill in:
| Field | Value |
|---|---|
| Record name | (leave empty for root domain, or www) |
| Record type | A |
| Alias | ✅ Yes |
| Route traffic to | Alias to Application Load Balancer |
| Region | us-east-1 |
| Load balancer | landmark-alb |
| Routing policy | Simple |
- Click Create records
After DNS propagation (1-5 minutes):
http://mylandmarktech.com
http://www.mylandmarktech.com
- Go to AWS Certificate Manager → Request certificate
- Domain:
mylandmarktech.comand*.mylandmarktech.com - Validation: DNS validation → Create records in Route 53
- Wait for status: Issued
- Go to ALB → Listeners → Add listener:
- Protocol: HTTPS : 443
- Default action: Forward to
landmark-tg - Certificate: Select your ACM certificate
- (Optional) Edit HTTP:80 listener → Redirect to HTTPS:443
To avoid charges, delete in this order:
1. Auto Scaling Group → Delete (will terminate instances)
2. Load Balancer → Delete
3. Target Group → Delete
4. Launch Template → Delete
| Issue | Check |
|---|---|
| ALB returns 503 | Target group has no healthy targets → check Security Group allows port 80 |
| Instances unhealthy | Health check failing → SSH in and verify curl localhost works |
| Domain not resolving | Check Route 53 alias record → confirm ALB is Active |
| Can't access on port 80 | Security Group on instances must allow HTTP from ALB's security group |
| ASG not scaling | Check scaling policy → CloudWatch alarm must be configured |