Schedules - Instance Scheduler on AWS

Schedules

Schedules specify when Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Relational Database Service (Amazon RDS) instances should run. Each schedule must have a unique name, which is used as the tag value that identifies the schedule you want to apply to the tagged resource.

Periods

Each schedule must contain at least one period that defines the time(s) the instance should run. A schedule can contain more than one period. When more than one period is used in a schedule, Instance Scheduler on AWS will apply the appropriate start action when at least one of the periods is true. For more information, refer to Periods.

Time zone

You can also specify a time zone for the schedule. If you do not specify a time zone, the schedule will use the default time zone you specify when you launch the solution. For a list of acceptable time zone values, refer to the TZ column of the List of tz database time zones.

Hibernate field

The hibernate field allows you to use hibernation for stopped Amazon EC2 instances. If this field is set to true, your EC2 instances must use an Amazon Machine Image (AMI) that supports hibernation. For more information, refer to Supported Linux AMIs and Supported Windows AMIs in the Amazon EC2 User Guide. Hibernation saves the contents from the instance memory (RAM) to your Amazon Elastic Block Store (Amazon EBS) root volume. If this field is set to true , instances are hibernated instead of stopped when the solution stops them.

If you set the solution to use hibernation, but your instances are not configured for hibernation or they do not meet the hibernation prerequisites , the solution logs a warning and the instances are stopped without hibernation. For more information, refer to Hibernate your On-Demand Instance or Spot Instance in the Amazon EC2 User Guide.

Enforced field

Schedules contain an enforced field that allows you to prevent an instance from being manually started outside of a running period, or manually stopped during a running period. If this field is set to true and a user manually starts an instance outside of a running period, the solution will stop the instance. If this field is set to true, it also restarts an instance if it was manually stopped during a running period.

Retain running field

The retain_running field prevents the solution from stopping an instance at the end of a running period if the instance was manually started before the beginning of the period. For example, if an instance with a period that runs from 9 AM to 5 PM is manually started before 9 AM, the solution will not stop the instance at 5 PM.

SSM maintenance window field (only applies to EC2 instances)

The ssm-maintenance-window field allows you to automatically add an AWS Systems Manager maintenance window as a running period to a schedule. When you specify the name of a maintenance window that exists in the same account and AWS Region as your deployed stack to schedule your Amazon EC2 instances, the solution will start the instance before the start of the maintenance window and stop the instance at the end of the maintenance window if no other running period specifies that the instance should run, and if the maintenance event is completed.

Once the SSM Maintenance window is created and the schedule is configured with the name of the SSM maintenance window, the changes are picked up at the next scheduled run of the Lambda. For example, if you selected a frequency of 5 minutes for the scheduler lambda to run, the maintenance window changes will only be picked up by the lambda any time between 1-5 minutes.

This solution uses the AWS Lambda frequency you specified during initial configuration to determine how long before the maintenance window to start your instance. If you set the Frequency AWS CloudFormation parameter to 10 minutes or less, the solution will start the instance 10 minutes before the maintenance window. If you set the frequency to greater than 10 minutes, the scheduler will start the instance the same number of minutes as the frequency you specified. For example, if you set the frequency to 30 minutes, the scheduler will start the instance 30 minutes before the maintenance window.

The Enable SSM Maintenance windows in the solution stack should be set to Yes and the stack should be updated, so that the solution will start loading the SSM maintenance window into the DynamoDB table, which will be used when the AWS Lambda function runs.

For more information, refer to AWS Systems Manager Maintenance Windows in the AWS Systems Manager user guide.

Override status field

Schedules also contain an override_status field that allows you to temporarily override the solution’s start and stop actions. If you set the field to running, the solution will start but not stop the applicable instance. The instance will run until you stop it manually. If you set the field to stopped, the solution will stop but not start the applicable instance. The instance will not run until you manually start it.

Note

If you set the override_status field to running but use the enforced field to prevent an instance from being manually started outside of a running period, the solution will stop the instance. If you set the override_status field to stopped but use the enforced field to prevent an instance from being manually stopped during a running period, the solution will restart the instance.

Instance type

For Amazon EC2 instances only, a schedule allows you to specify an optional instance type for each period in a schedule. When you specify an instance type in the period, the solution will start the Amazon EC2 instance with the applicable instance type.

To specify an instance type, use the syntax <period-name>@<instance-type>. For example, weekends@t2.nano. Note that if you specify an instance type for a period that schedules Amazon EC2 instances and Amazon RDS instances, the instance type will be ignored for Amazon RDS instances.

If the instance type of a running instance is different than the instance type specified for the period, the solution will stop the running instance and restart the instance with the specified instance type, if the specified instance type is compatible with the instance configuration of the running instance. For more information, refer to Change the instance type in the Amazon EC2 User Guide for Linux Instances.

Schedule definitions

The Instance Scheduler on AWS configuration table in Amazon DynamoDB contains schedule definitions. A schedule definition can contain the following fields:

Field Description
description An optional description of the schedule.
hibernate

Choose whether to hibernate Amazon EC2 instances running Amazon Linux. When this field is set to true, the scheduler will hibernate instances when it stops them. Note that your instances must turn on hibernation and must meet the hibernation prerequisites.

enforced Choose whether to enforce the schedule. When this field is set to true, the scheduler will stop a running instance if it is manually started outside of the running period or it will start an instance if it is stopped manually during the running period.
name The name used to identify the schedule. This name must be unique.
periods

The name of the periods that are used in this schedule. Enter the name(s) exactly as it appears in the period name field.

You can also specify an instance type for the period using the syntax <period-name>@<instance-type>. For example, weekdays@t2.large.

retain_running Choose whether to prevent the solution from stopping an instance at the end of a running period if the instance was manually started before the beginning of the period.
ssm_maintenance_window

Choose whether to add an AWS Systems Manager maintenance window as a running period. Enter the name of a maintenance window.

Note

To use this field, you must also set the use_maintenance_window parameter to true.

Note

This feature only applies to EC2 instances.

stop_new_instances

Choose whether to stop an instance the first time it is tagged if it is running outside of the running period. By default, this field is set to true.

timezone The time zone the schedule will use. If no time zone is specified, the default time zone (UTC) is used. For a list of acceptable time zone values, refer to the TZ column of the List of tz database time zones.
use_maintenance_window Choose whether to add a maintenance window as a running period to an instance schedule, or to add an AWS Systems Manager maintenance window as a running period to an Amazon EC2 instance schedule. For more information, refer to SSM Maintenance Window Field.
use_metrics

Choose whether to turn on CloudWatch metrics at the schedule level. This field overwrites the CloudWatch metrics setting you specified at deployment.

Note

Enabling this feature will incur charges of $0.90/month per schedule or scheduled service.