In a previous post
AWS CloudWatch Events allows us to schedule automated actions on a schedule using cron or rate expressions. CloudWatch Events use targets to specify the action and the targets can be different AWS services. EC2 instances, Step Function, Lambda Functions and Batch jobs are among some of the targets.
In its simplest form, the CloudWatch Event triggers on a specified
Procedure:
Select CloudWatch service from the console and navigate to ‘Events’and click on ‘Rules’ to bring you to a second screen similar to this.
Click on ‘Create rule’ to reach the next screen where you will select ‘Schedule’ and enter the cron expression corresponding to the time when you want to start execution of your function.

The cron is similar to what you would use on a Linux server so it is easy to figure it out.
0 10 * * ? * implies Run everyday at 10:00 am UTC
Once you enter the time, the console will show you the next 10 Trigger dates corresponding to your cron expression. This is a good way to validate your expression. If the triggers look incorrect, make adjustments to your cron expression.

It is best to review the AWS documentation for the cron expression so as not to make a mistake. All scheduled events use UTC time zone. I have provided the link below in this post to read more on the cron expressions.
Next click on ‘Add target’ on the right-hand side of the screen. Select ‘Step Function state machine’ from the drop down and let AWS create the role for you if you don’t have one already. Click ‘Configure details’ button and enter a name for the rule and description.

That’s all there is to be done, now at the scheduled time, your function will execute and start the server for you.
If for any reason you wanted to disable the schedule you could do that from the Rules page. Select your rule and from the ‘Action’ select enable or disable as needed.
Further reading:
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/WhatIsCloudWatchEvents.html
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/Create-CloudWatch-Events-Scheduled-Rule.html
- https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html#CronExpressions