How to avoid a forgotten EC2 bankrupting you
Quite often I find myself tinkering while using my personal AWS account when dealing with OS or other services. One “gotcha” that can happen is a forgotten EC2 instance. Next thing you know your typical $1 monthly bill is now $20 or more.
I have this set in my instance by default (I do not maintain any long-running ec2 instances). So if I spin a box up to experiment with something and I forget about it it will shut down after 2 hours of inactivity. If it is a spot instance or if you change the shutdown behavior to terminate it will completely delete the instance and disk. Worse case you have a forgotten disk. Not $0 but better than a running instance. Hope this helps
If it is a systemd os you can add: