AWS Instance Power Scheduler

Purpose

The purpose of the AWS Power Scheduler is to save costs in the cloud by preventing unnecessary run hours for various resource types in AWS. Since compute is charged per hour, often times non-production and non-critical workloads can be turned off outside regular business hours for tangible savings. This solution enables easy scheduling of resource run times across multiple services for any number of AWS accounts and regions, in a single streamlined user interface.

Example 1: Scheduling resources OFF during the weekends to save 28.5% of compute costs.

Example 2: Scheduling resources OFF during the weekday nights & weekends to save up to 70% of compute costs.

Requirements

  • Onboard AWS accounts into a regional target group
  • E1 Permissions: describe, start, and stop for each service to be included

Supported Resources

  • EC2 Instances
  • EC2 AutoScaling Groups
  • RDS Instances
  • Aurora Clusters
  • DocumentDB
  • Neptune Database Instances
  • Sagemaker Notebook Instances

Commands

  • Scan Instances: Run this command with a target group of AWS accounts and specified regions to populate the system with all supported resource types. Optionally, you can choose to exclude resource types from being included in the system. For an existing system dataset, adding a new exclusion will remove any pre-existing resources of that matching type.
  • Stop Instance: Select resource(s) from the system data table and run this command to stop the instance.
  • Start Instance: Select resource(s) from the system data table and run this command to start the instance.
  • Assign Group: Select resource(s) from the system data table to assign a group name.
  • Stop Group: Run this command with a group name to stop all resources assigned with the matching group name.
  • Start Group: Run this command with a group name to start all resources assigned with the matching group name.
  • Clear Dataset: Deletes the entire system dataset. This action is irreversible and all group assignments will be lost.

How-to use

  1. Execute Scan Instances command with your target group of AWS accounts & regions to populate resources data.
  2. Assign a Group to your resources using the Assign Group command based on scheduling criteria (timezone, environment, etc.)
  3. Schedule Stop Instance, Start Instance, Stop Group, and Start Group commands to set running hours that mirror hours of productivity.

Adding New AWS Resource Types

  1. Add resource collector logic to Scan Instances command, using add_info function to initialize, and including these mandatory fields: Name, (UNIQUE) InstanceId, State, and Service.
  2. (Optional) Add new bool input field for ability to exclude new service from Scan Instances.
  3. (Optional) Add logic for any user-definable state data to the section labeled # Last Step: Preserve stateful data.
  4. Add logic to the Stop Instance, Start Instance, Stop Group, and Start Group commands for interfacing with the new Service.

Notes

  • Although you can schedule individual resources, it is best practice and easier to manage this solution long-term using the Group method.
  • Stop Instance and Start Instance commands are great for on-demand power on/offs.
  • Subsequent runs of the Scan Instances command will preserve stateful Group data.
  • Although uncommon, it is possible that AWS may not have capacity to power a resource back on. For cases such as this, it is recommended to setup an automated alert for a failure to start, so that retries and other options can be considered.
  • The Scan Instances command saves the last known valid configuration for AutoScaling Groups, or where MinSize, MaxSize, and DesiredCapacity values are not all equal to zero.
  • Scheduling is done in UTC, so Daylight Savings Time (DST) adjustment should be considered.