Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There is a way to hack this up, which is probably a bit complex for a single instance, but works:

- Setup a HTTPS endpoint on the server that listens for an SNS notification and performs an action (e.g. backup ephemeral data to S3 and shutdown). I wrote the service in Go and the action is just a shell script but choose your favorite language.

- Setup an SNS subscription pointing to the service endpoint.

- Setup an SNS topic for the message.

- Set up an SNS notification in AWS billing. I use "When actual costs are equal to 100% of budgeted amount".

The problem is that it's necessary to lock down the endpoint listener as it will usually need root access in order to shutdown the machine. This can be done by using authentication on the endpoint, setting up a locked down user to run the service under and granting that user the ability to run /sbin/shutdown in the sudoers file.

There are probably nicer ways to do it, but this does work to limit my spend on each instance.

You can also add AWS API calls to delete any other costly related resources (static IPs, load balancers etc.)

I've been thinking about writing a more modular and robust app that handles multiple instances etc but most of my servers are now in GCE so I don't really have the need.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: