AWS Instance Scheduler
AWS Instance Scheduler

Appendix D: Custom Resource

You can use the Instance Scheduler’s AWS CloudFormation custom resource (ServiceInstanceSchedule) to configure schedules and periods. The custom resource uses the same names and syntax as the fields in the configuration Amazon DynamoDB table. For more information on the fields for schedules, see Schedule Definitions. For more information on the fields for periods, see Period Definitions.

When using the custom resource to configure a schedule or period, you must include the account, AWS Region, and name of the deployed schedule stack in the ServiceToken field.

The following sample custom resource code shows a schedule (OfficehoursNL) that contains two periods.

"OfficehoursNL": { "Type": "Custom::ServiceInstanceSchedule", "Properties": { "Description": "Weekdays in NL", "ServiceToken": "arn:aws:lambda:<region>:<accounted>:function:<scheduler-stackname>-InstanceSchedulerMain", "Enforced": "True", "Timezone": "Europe/Amsterdam", "Periods": [ { "Description": "Opening hours on weekdays", "BeginTime": "09:00", "EndTime": "18:00", "WeekDays": "Mon-Fri" }, { "Description": "Opening hours in weekend", "BeginTime": "10:00", "EndTime": "16:00", "WeekDays": "Sat-Sun" } ] } },

Do not use the DynamoDB console or scheduler CLI to delete or modify schedules and periods that were configured using the custom resource. If you do, you will create a conflict between the stored parameters in the stack and the values in the table. Also, do not use periods configured using the custom resource in schedules created using the DynamoDB console or the scheduler CLI.

Before you delete the main Instance Scheduler stack, you must delete all additional stacks that contain schedules and periods created using the custom resource because the custom resource stacks contain dependencies on the main stack’s DynamoDB table.

In the configuration DynamoDB table, schedules and periods that were configured with the custom resource can be identified by the configured_in_stack attribute. The attribute contains the Amazon Resource Name of the stack that was used to create the item.