Eu mesmo resolvi, escrevi uma função lambda em Python e a executava a cada hora pelo agendador de eventos no AWS CloudWatch
import json
from botocore.vendored import requests
import boto3
import time
region = 'xx-xxxx-x'
instances = ['x-xxxxxxxxxxxx']
website = 'https://website.com/'
webstring = 'SearchText'
def lambda_handler(event, context):
for i in range(0,3):
if check_website():
return 'Website OK'
time.sleep(60)
reboot_instance()
return 'Restarted instances'
def check_website():
r = requests.get(website)
if webstring in r.text:
return True
else:
return False
def reboot_instance():
ec2 = boto3.client('ec2', region_name=region)
ec2.reboot_instances(InstanceIds=instances)