Alex Glikson
Alex Glikson

Reputation: 441

scheduled execution of tasks on AWS?

As part of an application running on AWS, I need to schedule execution of certain simple tasks (which could be Lambda functions, for example), based on an explicit specification of date and time for each (not necessarily periodic). As part of the application logic, it would occasionally add/modify some of the pending tasks (e.g., by calling some API).

Is there an easy way to do it using AWS services (or a 3rd party cloud service, accessible via API), without maintaining my own micro-service for this?

UPDATE: CloudWatch supports cron-style events, but it doesn't seem to be designed for ad-hoc events (e.g., number of rules is limited to 100 by default).

Upvotes: 1

Views: 98

Answers (1)

hephalump
hephalump

Reputation: 6164

Yes, you can do this. Lambda supports CloudWatch Events as triggers; you can create a Cron event/rule in CloudWatch which will trigger your Lambda on the defined schedule. If you only need invocations at specific dates and times you can use the "Cron Expression" to define that specific date/time.

Go to Cloudwatch and click on Rules in the left hand vertical menu, then click on "Create Rule" in the right hand pane:

Create CloudWatch rule

Next click on schedule and define your schedule, and then click on "Add Target" and you'll be able to select your Lambda function as the target.

Create CloudWatch rule

A significant gotcha to know about is that the cron is limited to one time per minute; if you need to invoke on a schedule faster than that you'll need to use another solution.

You can read more about CloudWatch rules and setting schedules here.

Upvotes: 1

Related Questions