I have an application load balancer that contains several EC2 spot instances.
I found that one of them was terminated because of BidEvictedEvent
, i.e., someone requested a spot instance with a price higher than mine.
The BidEvictedEvent
made my web service unavailable (502 bad gateway
) for a few seconds.
So I want to execute a script that detaches the EC2 from the auto-scaling group before it got terminated.
Now my question is, how can I simulate BidEvictedEvent
so that I can make sure that my script got executed correctly?
I've tried terminating the EC2 instance from AWS console. But this doesn't create 502 bad gateway
for the client of my web service when there's no script executed before EC2 termination.
I use the method mentioned here to monitor when the BidEvictedEvent occurs.