Automate maintenance mode

Automate maintenance mode

We stop multiple AWS Ec2 instance multiple times in a day so I am looking for a way to automate maintenance mode. I want that as soon as any EC2 instance is stopped, it should be placed on to maintenance mode and as soon as it is started, the maintenance mode should turn off itself. Is this scenario achievable using site24x7?