Friday, November 7, 2025

Creating EC2 Launch Template for Auto Scaling Web Server

Creating EC2 Launch Template for Auto Scaling Web Server


Step 1: Create a Launch Template

Go to EC2 Dashboard → Launch Templates → Create launch template

Fill in:

Name: WebServerTemplate
AMI: Amazon Linux 2 (or your preferred AMI)
Instance Type: t2.micro/t3.micro (Free Tier Eligible)
Key Pair: Select your key
Security Group: Must allow HTTP (port 80)

User Data:

#!/bin/bash
# Update the package index
sudo su
yum update -y

# Install Apache HTTP server
yum install -y httpd

# Install Stress Command
yum install -y stress

# Start the httpd service
systemctl start httpd

# Optional: Create a simple index.html page
echo "<h1>Hello from EC201</h1>" > /var/www/html/index.html

# Enable httpd to start on boot
chkconfig httpd on

✅ Enable Auto Scaling guidance At the bottom of the form, check the box labeled “Provide guidance for Auto Scaling”. This ensures the template is optimized for use with Auto Scaling Groups.

Click Create launch template

No comments:

Post a Comment