Automated Healing

In the previous lab we setup EventBridge rules to automatically respond to events in our AWS environment. In this section we will see those rules in action.

  1. Connect to instance and generate CPU load.

    • In your AWS Console, navigate back to Systems Manager
    • Under Node Management, click the option for Session Manager
    • Click the button Start session
    • Select one of the Lab App host instances, and click the button Start session
    • In the terminal session, run the 3 commands below to enable the EPEL respository and install the stress utility
    sudo amazon-linux-extras install epel -y
    sudo yum install stress -y
    which stress
    
    • You should see an output of /usr/bin/stress after the final command, confirming the installation.
    • Enter the command stress --cpu 2 to generate load on the 2 cpus
  2. After a few minutes the automation setup in the previous lab will kick in, let’s observe to outcomes.

    • Return to CloudWatch Alarms and keep an eye on the CPU alarms, it will transition to Alarm State after a few minutes. SessionStart
    • The first EventBridge rule to terminate the instance will trigger. Check in the EC2 Instances console and you should see the instance in the Shutting Down state. SessionStart
    • You should also receive an email notifying you of the termination. SessionStart
    • In a few minutes, the autoscaling group will launch a new instance to replace the one which was terminated. SessionStart
    • You should see the CPU alarm was automatically created for the new instance. SessionStart
    • You can also check in the SSM Automation execution history to see the log of the automations SessionStart