top | item 24245166

Show HN: Tiny CLI to save AWS costs in dev environments when you're sleeping

119 points| aramalipoor | 5 years ago |npmjs.com | reply

55 comments

order
[+] aramalipoor|5 years ago|reply
Just published a tiny CLI utility to save some bucks on AWS development environment while I'm not really working.

https://github.com/aramalipoor/aws-cost-saver

The idea is to stop/shutdown any resources (such as EC2 instances, RDS databases, ECS tasks, etc.) when you're done for the day and restore them back up next time you continue.

Currently it's in a very early stage, a hobby side-project :)

Ideally I'm thinking to provide a CloudFormation template or terraform config for example, to provision a scheduled Lambda with predefined "start of work" and "end of work" times and have it automatically do that for you.

I'd like to know if something like this would be useful for you too and what do you think about it?

[+] vageli|5 years ago|reply
Are you aware of cloud custodian out of Capital One? [0] Does this and much, much more (like delete noncompliant security groups, etc).

[0]: https://cloudcustodian.io/

[+] WrtCdEvrydy|5 years ago|reply
This is amazing....

Edit: I wonder if you could put this inside of a lambda with just a role.

[+] adamlklein|5 years ago|reply
This sounds like a good idea!

I had been looking at creating a lamba to check for the existence of pods, services, alternate namespaces etc., as I learn K8s on AWS, to shut down the cluster when I'm not working on it.

[+] z3t4|5 years ago|reply
Im very interested in learning about your work flows, like how does a typical day look like? I do all my work on a local pc and only use servers for production. So im interesting in how/why you use the cloud stack
[+] swyx|5 years ago|reply
interesting work! i feel like this can't be a new problem. what comparable tools exist for doing this today? its basically just spinning up a staging env while you work and spinning down when you knock off work right? almost like a heroku dyno spinning up for you.
[+] fareesh|5 years ago|reply
Is it common to have a dev environment on AWS? I just use it for production and maybe staging. Staging is scheduled to run during office hours.
[+] ldoughty|5 years ago|reply
Ops people need a Dev environment to test, especially for Infrastructure as code. With an increased connectivity between developer code and Infrastructure, I prefer my team finds out everything in a development environment that's exactly like staging and prod. That way deployment to staging is proof of the IAC change. There's less risk.

This also lets developers try out new services in the cloud without impacting the staging... (This is on top of a sandbox for research, but integration of research takes time and an environment too)

[+] vitalysh|5 years ago|reply
I guess depends on the size of the company. How else would you constantly test integrations between different services? Especially if some services can't be easily ran on the laptop.

Also if you add terraform/ansible and all that jazz to the table. Where else? Infra team needs dev/stage as well.

[+] mcintyre1994|5 years ago|reply
It’s super useful to be able to spin up a dev environment for doing things like experimenting with the performance impact of different configs. It’d be annoying and potentially disruptive to other team members to do that on staging.
[+] carnitas|5 years ago|reply
My company tasked me to mad dash their dev environment to AWS. Why? Because “cloud”, and perceived less risky than moving QA and Prod first.
[+] weeefun|5 years ago|reply
It looks like a nice tool doing it's job well :-) I'd also consider services like provisioned DynamoDB tables or Kinesis streams in this context because there you can also waste lots of money depending on your setup. For example, you could decrease the provisioned read/write capacity for a DynamoDB table or decrease the shards of a Kinesis stream over night. I've discussed these topics in a blog post, in the context of a CloudFormation stack, if anyone's interested: https://www.sebastianhesse.de/2018/04/22/shut-down-cloudform...
[+] aramalipoor|5 years ago|reply
Thanks for sharing your experience. Both of them sounds like great ideas, will add them to ToDo right away :)
[+] iflowfor8hours|5 years ago|reply
Great addition to pile of scripts to take with you on problem solving missions. I have something similar, but written in terraform. WRT AWS cost visibility, I find it is usually faster to spin up and grab most of the relevant information using mlabouardy's [komiser](https://github.com/mlabouardy/komiser) than to try and standardize yourself. Not shilling, just a tool I like.
[+] stekern|5 years ago|reply
If you're using IaC and have it set up in a CI/CD pipeline, you could also achieve the same by having a cronjob set a flag outside of work hours, and use conditionals in your IaC based on the value of that flag (e.g., for Terraform `count = var.scale_down ? 0 : 1`)
[+] aramalipoor|5 years ago|reply
There were a few reasons why I couldn't use IaC:

1) Using conditionals to achieve this usually makes terraform unmanageable specially if your terraform is complex.

2) Sometimes you'd need to do more complex steps to save some money, for example in case of ElastiCache you'd need to snapshot/delete/create.

3) Using terraform in a Lambda to schedule this was not straightforward (in my current company) so I gave up making it work :D

[+] kevin_nisbet|5 years ago|reply
While this only works with instances, I usually just cron the shutdown command with a future time. Nice thing is, if working late I give myself a couple hour window to cancel shutdown on any nodes I'm still using.

echo "0 22,0,2,4,6,8,10 * * * /sbin/shutdown +115" > /etc/cron.d/autoshutdown

I'm all for a better tool, just wanted to point out a builtin alternative.

[+] ngcc_hk|5 years ago|reply
Any similar for other cloud services like azure, gcp and especially digital ocean
[+] dabeeeenster|5 years ago|reply
This is awesome - Does it work cross-region?

+1 to add in:

- Elasticache instances - Load balancers associated with ECS clusters

[+] 60secz|5 years ago|reply
Because my favorite place for AWS credentials is some random NPM module?
[+] debaserab2|5 years ago|reply
This works like every other AWS CLI tool - it uses your shells AWS credentials dir or ENV vars
[+] barkingcat|5 years ago|reply
I find it price gouging that AWS doesn't already implement this on their own within their pricing structure and that you need a 3rd party tooling to do this.
[+] aliswe|5 years ago|reply
Are you seriously alleging that NOT implementing a "stop resources when I sleep/am not around" feature amounts to price gouging?
[+] bufferoverflow|5 years ago|reply
If you don't like their prices, why don't you just switch to another provider? Plenty of good clouds. And even more dedicated / VPS servers, if you want truly crazy savings.
[+] pc86|5 years ago|reply
That's not what price gouging is.
[+] cybrix|5 years ago|reply
They earn more money by not doing this.