๐Ÿงช Lab 3: Cloud Operations and Scaling (AWS, RHEL)

Course: CompTIA Cloud+ CV0-004
Objective: Monitor cloud instances and configure auto-scaling using AWS Free Tier and RHEL.


๐ŸŽฏ Goals


Setup RHEL EC2 Instance with Monitoring

  1. Launch a new EC2 Instance:
  2. AMI: Red Hat Enterprise Linux 9
  3. Type: t2.micro (Free Tier)
  4. Name Tag: cloudplus-monitor
  5. Enable Public IP
  6. In the User Data section, paste the following script:
#!/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
  1. Create and attach a Security Group allowing:
  2. Port 22 (SSH)
  3. Port 80 (HTTP)

  4. Connect to your instance via SSH:

chmod 400 cloudplus-key.pem
ssh -i "cloudplus-key.pem" ec2-user@<your-public-ip>

Enable CloudWatch Monitoring

  1. Go to CloudWatch โ†’ Log groups:
  2. Create a new log group: cloudplus-monitoring

  3. Install the CloudWatch Agent:

sudo dnf install -y amazon-cloudwatch-agent
  1. Create a configuration file:
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
  1. Start the CloudWatch Agent:
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.


Set Up Auto Scaling

  1. Go to EC2 > Launch Templates โ†’ Create template:
  2. Name: cloudplus-template
  3. Use the same RHEL AMI, instance type, key pair, and security group as above

  4. Go to Auto Scaling > Auto Scaling Groups โ†’ Create:

  5. Use cloudplus-template
  6. VPC and subnet: Same as previous labs
  7. Desired capacity: 1
  8. Min: 1, Max: 2

  9. Add a Scaling Policy:

  10. Target tracking: Average CPU โ‰ฅ 60%
  11. Cooldown period: 300s

  12. Generate CPU load to test scaling:

yes > /dev/null &

โœ… Checkpoint: Watch the Auto Scaling group create a new instance when CPU usage rises.


โœ… Lab Complete

You have now configured monitoring, logging, and an auto-scaling policy for RHEL on AWS Free Tier.