A while ago, I needed a small VPS for my students to practise both in class and at home. I was paying for it myself, so I needed it to be as cheap as possible.

I decided to use an AWS Lightsail VPS: back then, I did not have enough computing power at home to self-host it, and for a disposable machine, with no data on it, a bit of public cloud was not a problem for me.

My students did not need the VPS to be up 24/7 : only during classes and when doing their homework (for those who did it ;p). So I wondered if there would be a way to pay for the VM only when it is running…

I came up with a very basic solution :

  • A simple Flask web portal allowing my students to :
    • inquire about the state of the VPS
    • start the VPS for a given amount of time (if it is down)
    • see how much running time they have left, and extend it (if it is up)
  • A set of python scripts based on Amazon’s boto3 handles the VPS lifecycle :
    • When the time is up, it :
      • shuts down the VM
      • snapshots the VM
      • deletes the VM
    • When a VM startup is requested, it simply creates a VM from the snapshot

Of course, this all makes sense only because snapshot storage fees are very low and my VPS was very lightweight (less than 8GB to snapshot, which cost me less than 50 cents a month).

The only drawback is that the IP address changes every time we re-create the VPS. I got around this by :

  • displaying the IP address on the web portal
  • setting-up DynDNS on the VPS, using one of my domains

Of course, I used ansible to set-up the VM so I could reproduce it the following year 😉

Everything is available on my github

Login Page

Status Page


Update, November 2026

There you go: I did not exactly reinvent the wheel here, but this quick little hack saved me quite a bit of money while giving my students real working comfort. I am not teaching at the moment, but when I start again, I think we will simply go with a Proxmox VM, now that I have (more than) enough computing power.