aws-solutions / instance-scheduler-on-aws

A cross-account and cross-region solution that allows customers to automatically start and stop EC2 and RDS Instances
https://aws.amazon.com/solutions/implementations/instance-scheduler-on-aws/
Apache License 2.0
542 stars 264 forks source link

Skip the stopping of an instance when 'in use' #524

Open keithrochford opened 6 months ago

keithrochford commented 6 months ago

Is your feature request related to a problem? Please describe. It would be nice to avoid stopping an instance when certain conditions are met, for exmple if a user leaves a long-running job on an instance it would be nice to skip (or defer) the stopping of that instance so that the computation would be allowed to complete.

Describe the feature you'd like If CPU utilisation was a suitably general measure of 'in use' then there could be a tag on the instance with a CPU value and if the utilisation is above that value then the stopping of the instance is skipped.

A more general solution might be to use a tag value that includes a CloudWatch metric name, a comparison operator and a value. If this condition evaluates to true, then skip the instance.

In the most simple scenario this would mean that the instance is not stopped until the next time the schedule determines that it should be stopped thus avoiding any intermediate retry of deferred stops.

Additional context

It occurs to me that defining a maintenance window to avoid the stopping of the instance might provide a approach to solving for this however the creation of that maintenance window would have to be automated in order to avoid the overhead of setting it on an instance-by-instance basis. The duration of the window could be defined using another tag so that the user could determine a maximum time for which the stopping of the instance would be skipped..

CrypticCabub commented 6 months ago

Hi Keith,

Thanks for the feature request. I'll take this to the team so that we can evaluate whether it would be feasible or not