This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple EC2 scheduler with AWS Lambda (NodeJs) function (start during working hours only, stop otherwise). | |
// https://gist.github.com/tteskac/0ab34617652433d70b8fc59eb444a85f | |
// | |
// The example code below checks if specific EC2 instance should be running or be stopped to save money. | |
// This is extremely useful e.g. for development/testing instances to be running only during working hours. | |
// Below in the code it is specified to run it Monday-Friday between 5-16 (UTC). | |
// In addition, it will not shutdown the instance if the CPU usage is above idle state, | |
// e.g. if someone is still using it a bit more outside working hours or some long processing is still happening. | |
// Use EventBridge (CloudWatch Events) to trigger this lambda function every hour. | |
// |