Run cloud functions on an interval

The @scheduled primitive creates stateless functions that run on a schedule.

🚜 Work Locally

An example .arc file:


cleanup rate(1 day)
tweet rate(1 hour)

Architect generates the following functions:

  • src/scheduled/cleanup
  • src/scheduled/tweet

🌾 Provision

Scheduled functions create the following AWS resources:

  • AWS::Events::Rule
  • AWS::Lambda::Function
  • AWS::Lambda::Permission

Protip: increase timeout in .arc-config for longer running functions

⛵️ Deploy

  • arc deploy to deploy with CloudFormation to staging
  • arc deploy dirty to overwrite deployed staging lambda functions
  • arc deploy production to run a full CloudFormation production deployment

🕰 Expressions

Scheduled functions can be configured with either rate or cron.

Rate expressions are simpler to define but don't offer the fine-grained schedule control that cron expressions support. For example, with a cron expression, you can define a rule that triggers at a specified time on a certain day of each week or month. In contrast, rate expressions trigger a rule at a regular rate, such as once every hour or once every day.
AWS Scheduled Events Docs

Example .arc:


daily-task rate(1 day)
check-email rate(10 minutes)
tweet cron(0/20 * ? * MON-FRI *) # every 20 mins weekdays

🎉 Event Payload

The function is invoked with a payload that has the following useful keys:

  • account - the current AWS account number
  • time - timestamp
  • region - current AWS region
  • resources - current executing ARN