There are automation options you could develop with the EC2 API, but you would need an always online machine to do it.
The preferred scenario within ec2 is to have a load balancer send traffic between two machines using a shared nothing architecture (This means persistent data would be on s3, or database that is not on the instance).
If your application does not allow for this, you can set up a backup instance which will health check your primary instance. Using a custom script, if the health check rules fail, you would remap and elastic IP address to the backup instance and then terminate and relaunch your primary instance. Once the health check works again, you could automatically return the ip to the primary instance. This would probably be easier to set up in VPC rather than classic as you would have control of private IP addresses.