aramalipoor / aws-cost-saver

A tiny CLI tool to help save costs in development environments when you're asleep and don't need them!
MIT License
305 stars 9 forks source link

Issue: OVERWRITE existing state-file #29

Closed karthikholla closed 4 years ago

karthikholla commented 4 years ago

When using --state-file s3:// on a daily scheduled cron., the job fails for the second time and further with error

→ State file already exists: s3://***/staging-state-file.json ? Are you sure you want to OVERWRITE existing state-file? You will not be able to restore to previously conserved resources! (y/N)

Please enable overwrite flag while using --state-file s3://

aramalipoor commented 4 years ago

Hi Karthik, thanks for trying out aws-cost-saver :)

Do you think using this approach of snapshotting an ideal state-file once and passing -n (i.e. --no-state-file) for the scheduled cron will work for your use-case?

If not, I'm happy to add an optional flag like --overwrite-state-file for you to try it out.

As you know I added this check to avoid overwriting a state-file that's not yet restored, maybe in case of dev/stage that's too strict 🤔

aramalipoor commented 4 years ago

Released -w|--overwrite-state-file in v0.1.0, let me know if it helps with your use-case.

karthikholla commented 4 years ago

Thanks @aramalipoor -n option wont work for me as we may have a couple of teams working on each environment and there is no ideal state file we can maintain. Each day the AWS resources get provisioned and de-provisioned as & when its required. Hence at the end of each day, we need to run this library to conserve all the running and restore it next day exactly.

yes. this rewrite functionality will definitely help us with that. Thanks for it. will try it out.