Full AWS Practitioner Certification Question

A company runs an application across thousands of EBS-backed Amazon EC2 instances. The company needs to ensure availability of the application and requires that instances are restarted when an EC2 instance retirement event is scheduled. How can this a DevOps engineer automate this task?