This might feel like a silly question but I ran into some issue where my EC2 instance was going down once in a while, now i have made some alternate to it, so that another instance will take over to this instance when this happens but i want to test this before i productionize the change.
I did some basic research on AWS blog post but don’t see any relevant answer.
Thanks in advance for the help!
2
Answers
The instance status check tries to connect to the instance and fails if it can’t.
An easy way to trigger an instance status check failure is to disable the default NIC in the instance. For Linux instances, run the following on startup:
If you are using CloudWatch alarms to trigger the takeover, you can use
set-alarm-state
command to simulate the alarm.Also, you seem to be reinventing a well-established pattern of an application load balancer with an autoscaling group with min/max/desired size set to one. ASG will replace the instance on the EC2 health-check failure out-of-the box, but you can also add an optional application health check on the ALB.