VeriorPies / MineCloud

An AWS CDK project to set up an almost free on-demand multiplayer server (Minecraft, Terraria, and more...) for a Discord community in just a few minutes
MIT License
290 stars 14 forks source link

[Question] How can the spot instance request issue be resolved? #69

Open mrumpf opened 1 year ago

mrumpf commented 1 year ago

I'm playing around with cdk deploy and cdk destroy to test the DNS name feature I requested in #68

The "cdk destroy" operation takes ages until it finally fails. I'm not 100% sure yet, but it seems as if the spot instance requests issue, you described somewhere in the comments, led to the issue that a second VM has been created, which does not get deleted by the cdk destroy operation and an attempt to delete the whole stack fails because the ENI is still in use by the second spot instance that is running.

aws ec2 describe-spot-instance-requests --query "SpotInstanceRequests[].SpotInstanceRequestId"

The question is whether there is a way to avoid a second VM to be started, becoming somehow detached from the CDK/CFN state?

mrumpf commented 1 year ago

I switched to the following properties:

        interruptionBehavior: SpotInstanceInterruption.TERMINATE,
        requestType: SpotRequestType.ONE_TIME,

and it seems to me that I had no more (or less?) VMs hanging around. There is still the issue with spot instance requests, but at least I could simply "cdk destroy" the whole setup without running into timeouts because of some detached VMs that were not seen by the CDK but blocking the ENI resources so that they could not be deleted.