- Monitor EC2 memory, disk, and CPU utilization using CloudWatch agent.
- Create dashboard with the metrics, and alert through slack when any alarm goes in alert status.
- Auto increase EC2 desired capacity, when CPU OR memory utilisation is greater than a threshold.
- Auto decrease EC2 desired capacity, when CPU AND memory utilisation is lower than a threshold.
sudo amazon-linux-extras install -y epel
sudo yum install -y stress htop
# CPU, and memory stress. t3.medium 2 CPU, 4GB memory
sudo stress --cpu 2 --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 5
# Memory stress. t3.medium CPU, 4GB memory
sudo stress --vm-bytes $(awk '/MemAvailable/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 5
# Disk utilization. 8GB disk
df -h
dd if=/dev/urandom of=2GB.bin bs=64M count=32 iflag=fullblock
dd if=/dev/urandom of=3GB.bin bs=64M count=48 iflag=fullblock
df -h
- The subnets are public to keep the stack simple; the focus is to showcase memory, cpu utilization and the autoscaling.
- Use the EC2 serial console to connect the instance.
The EC2 password is set to secret
from the UserData
. This is set ONLY for debugging purposes, so do we remove this command before using it on production.
make samconfig.toml
Customise as per you needs. Requires AWS::Chatbot::SlackChannelConfiguration from a different stack.make deploy