I want to exploit the AWS free tier to learn and do some personal projects. However what worries me is the bandwidth limitation. Specifically, the AWS free tier FAQ states that "15 GB of bandwidth out aggregated across all AWS services". Now, it is very unlikely that my intended use will reach this limit, however shit happens and who knows if my website gets mentioned on Reddit or something and suddenly I have a $500 dent in my wallet due to bandwidth. Or maybe someone decides it would be funny to DDoS my instance. Or who knows what.

What I would want to do is create some kind of killswitch. Basically when the amount of bandwidth used gets to something like 14GB, murder everything that uses bandwidth and keep it that way until I manually start it back up again.

Any ideas on how to achieve this?

  • Please note that even if you kill the service, if they DDoS, the traffic still go to your server door step. (thus accounted anyhow). If lucky they target your DNS, so you can change your DNS to something like To give an example, I got targeted of a DDoS of 6g for a day even if hoster closed the server. (lucky for me, it was a unlimitted bandwidth hoster)
    – yagmoth555
    May 16 '16 at 15:55

A simple way to do this would be to create a bash script and use some network bandwidth tool, there are many options to check bandwiwdth/traffic (bmon, nload, etc) on your server. In that script, after you found the current total bandwidth, put a statement like:

if threshold reached:
    shutdown myWebApp # kill the service


And then once you have that bash script set up, add a cron to your crontab, say every 15 minutes or something:

*/15 * * * * /bin/bash /path/to/bash/script.sh

Not the answer you're looking for? Browse other questions tagged or ask your own question.