• DevOps
    Case Study

    How we built a resilient multi-account, multi-cloud solution for a Health Tech service provider!

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How we built a scalable Odoo solution for a Travel Tech service provider!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    How we built a scalable Odoo solution for TravelTech service provider!

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Contact Us

Connect with us!


LinkedInFacebookXInstagramYouTube

aws partneraws advanced partner
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

Auto-Restart EC2 Instances on Status Check Failure: Quick Setup Guide

Arya P B

  • 2 min read
Auto-Restart EC2 Instances on Status Check Failure: Quick Setup Guide

Generating audio, please wait...

Introduction

In this comprehensive guide, we’ll take you through the process of setting up an automated system to restart an EC2 instance when its status check fails using AWS CloudFormation. By creating a CloudWatch Alarm that specifically monitors “Status Check Failure” metrics and integrating it with Simple Notification Service (SNS), we can receive notifications and trigger an automatic restart. This ensures the health and availability of your EC2 instances, especially in scenarios where status check failures may impact performance and reliability.

Screenshot from 2024-02-07 23-13-24.png

Prerequisites

  • AWS Account
  • Basic knowledge of AWS CloudFormation

CloudFormation Template Overview

The CloudFormation template includes parameters, resources, and outputs. Key components:

  • Parameters: Customize with the existing EC2 instance ID.
  • Resources: Define CloudWatch Alarm, SNS Topic, and SNS Subscription.
  • Outputs: Display the EC2 instance ID.

Launch the CloudFormation Stack

  1. Access AWS CloudFormation.
  2. Choose “Create Stack” > “With new resources.”
  3. Upload the provided template.
AWSTemplateFormatVersion: '2010-09-09'
Description: Template to Create a CloudWatch alarm for EC2 instance status check failure

Parameters:
  ExistingInstanceId:
    Type: String
    Description: ID of the existing EC2 instance

Resources:
  SnsTopic:
    Type: AWS::SNS::Topic
    Properties:
      DisplayName: "EC2StatusCheckFailureTopic"
      
  SnsSubscription:
    Type: AWS::SNS::Subscription
    Properties:
      Protocol: email
      TopicArn: !Ref SnsTopic
      Endpoint: [email protected]  # Replace with your email address

  InstanceStatusAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmName: InstanceStatusAlarm
      Namespace: AWS/EC2
      MetricName: StatusCheckFailed
      Dimensions:
        - Name: InstanceId
          Value: !Ref ExistingInstanceId
      Statistic: Maximum
      Period: 300
      EvaluationPeriods: 1
      Threshold: 0.99
      ComparisonOperator: GreaterThanOrEqualToThreshold
      AlarmActions:
        - Ref: 'SnsTopic'
        - !Sub 'arn:aws:automate:${AWS::Region}:ec2:reboot'
      Dimensions:
        - Name: 'InstanceId'
          Value: !Ref ExistingInstanceId

    DependsOn: SnsSubscription
  1. Fill in parameters, including the ExistingInstanceId.
  2. Click through and “Create stack.”

    Screenshot from 2024-02-07 23-13-43.png
     

CloudWatch Alarm for Status Check Failure

The InstanceStatusAlarm is set to monitor the "StatusCheckFailed" metric. If it exceeds 0.99 for 300 seconds, the alarm triggers.

Simple Notification Service (SNS)

The template creates SnsTopic and SnsSubscription to your email. Replace the placeholder with your email for notifications.

Triggering Auto-Restart on Status Check Failure

  1. Wait for stack creation.
  2. Intentionally stop the EC2 instance or let it fail a status check.
  3. CloudWatch Alarm detects failure, triggers SNS notification.
  4. Check email for SNS notification.

Conclusion:

With this CloudFormation template, you’ve set up a quick and efficient system to automatically restart EC2 instances on status check failures. By integrating CloudWatch Alarms and SNS, you ensure prompt responses to keep your instances running smoothly.

Take charge of your AWS instance health! Deploy our CloudFormation template for automated EC2 restarts on status check failures. Swiftly monitor, get alerts, and enhance reliability. Elevate your AWS game — deploy now!

  • DevOps

Looking for AWS Experts?

We provide top-of-the-line custom AWS setup services tailored to your needs.

Auto-Restart EC2 Instances on Status Check Failure: Quick Setup Guide

Analyzing AWS IAM Users: Access Key and Password Age

Analyzing AWS IAM Users: Access Key and Password Age
  • DevOps
logo

Analyzing AWS IAM Users: Access Key and Password Age

Analyzing AWS IAM Users: Access Key and Password Age
  • AWS
  • DevOps
logo

Auto-Restart EC2 Instances on Status Check Failure: Quick Setup Guide

Auto-Restart EC2 Instances on Status Check Failure: Quick Setup Guide
  • AWS
  • DevOps
logo

Automatically Retrieve AWS Activated Regions Using AWS Lambda and Boto3

Automatically Retrieve AWS Activated Regions Using AWS Lambda and Boto3
  • DevOps
  • AWS
logo

Posts by Arya P B

Athena