Course: CompTIA Cloud+ CV0-004
Objective: Monitor cloud instances and configure auto-scaling using AWS Free Tier and RHEL.
t2.micro (Free Tier)cloudplus-monitor#!/bin/bash
sudo dnf update -y
sudo dnf install -y httpd
echo "<h1>Cloud Monitoring - RHEL</h1>" | sudo tee /var/www/html/index.html
sudo systemctl enable httpd
sudo systemctl start httpd
Port 80 (HTTP)
Connect to your instance via SSH:
chmod 400 cloudplus-key.pem
ssh -i "cloudplus-key.pem" ec2-user@<your-public-ip>
Create a new log group: cloudplus-monitoring
Install the CloudWatch Agent:
sudo dnf install -y amazon-cloudwatch-agent
sudo tee /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json > /dev/null <<EOF
{
"agent": {
"metrics_collection_interval": 60,
"logfile": "/var/log/messages"
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "/var/log/messages",
"log_group_name": "cloudplus-monitoring",
"log_stream_name": "{instance_id}"
}
]
}
}
}
}
EOF
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s
โ Checkpoint: Your instance logs should now appear in the CloudWatch console.
cloudplus-templateUse the same RHEL AMI, instance type, key pair, and security group as above
Go to Auto Scaling > Auto Scaling Groups โ Create:
cloudplus-templateMin: 1, Max: 2
Add a Scaling Policy:
Cooldown period: 300s
Generate CPU load to test scaling:
yes > /dev/null &
โ Checkpoint: Watch the Auto Scaling group create a new instance when CPU usage rises.
You have now configured monitoring, logging, and an auto-scaling policy for RHEL on AWS Free Tier.