algo icon indicating copy to clipboard operation
algo copied to clipboard

Allow the VM to self-destruct after 1 month

Open dguido opened this issue 9 years ago • 7 comments

Most people will use this script to setup a VPN when they travel. When they return home they might stop using the VPN and forget that the VM still exists. This will cost them money. Let's have the VM self-destruct after a given time period by default. 1 month sounds like a good timeframe.

This has security benefits as well, since an attacker would need to setup infrastructure, services, maybe get a warrant, etc to intercept traffic to/from your VPN server. Routinely rotating the infrastructure makes it much harder to "get a fix" on you.

Here's a great implementation of this idea:

  • https://github.com/richo/ephemera/blob/master/main.go#L145-L153

dguido avatar Jul 20 '16 18:07 dguido

According to your suggestion, there is only function to shutdown a VM, but not to destroy. As I know DigitalOcean continue to charge the money even a VM is down. So, there is no way to destruct a VM without a query to the API. But requests to the API from a VM is too insecure

jackivanov avatar Jul 24 '16 13:07 jackivanov

Darn, yes you are right. This might work on other providers but it does not work on Digital Ocean.

dguido avatar Jul 25 '16 21:07 dguido

This can integrated easily on providers such as EC2 as instances can be set to terminate on shutdown during creation.

defunctio avatar Jul 31 '16 20:07 defunctio

We could add a shell script to cron with the user's DigitalOcean token embedded and have it curl out the appropriate call to the API to terminate the instance... but that requires storing an API key in the cloud :-(

dguido avatar Aug 10 '16 17:08 dguido

For reasons why tearing down your infrastructure on a regular basis is important, see also "ShadowBrokers."

dguido avatar Aug 28 '16 07:08 dguido

If Docker Machine is used to provision the server, you can easily automate stop/removing it form your laptop or desktop. The only thing with this, is you'll have Docker installed on it, though I don't think that's much of a drawback.

finid avatar Dec 12 '16 15:12 finid

if deployed to AWS , this could be done with (a) lambda scheduled cron and (b) cloudformation delete-stack

tonymet avatar Feb 02 '20 02:02 tonymet