• Documentation
  • Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Serverless Framework Logo

Serverless Framework

Intro
SetupUpgrading To V4ConceptsTutorialAWS CredentialsLicense Keys
DeployingPackagingBuildingTestingDev ModeServicesFunctions
OverviewHTTP (API Gateway v2)REST (API Gateway v1)ActiveMQApplication Load BalancerAlexa SkillAlexa Smart HomeCloudWatch EventCloudWatch LogCloudFrontCognito User PoolEventBridge EventIoTIoT Fleet ProvisioningKafkaKinesis & DynamoDBMSKRabbitMQS3ScheduleSNSSQSWebsocket
LayersManaged InstancesWeb Apps (Lambda Web Functions)Sandboxes (Lambda MicroVMs)MCP ServersAlertsVersion PruningDomainsIAM Function PermissionsParameters
OverviewSelf-reference serverless.ymlServerless CoreEnvironment VariablesCLI OptionsExternal YAML/JSON FilesJavascript propertiesGitDoppler
OverviewS3 ObjectsSSM Parameter Store & Secrets ManagerCloudFormation Stack Outputs
OverviewVaultTerraform State Output
ResourcesComposing ServicesDeployment BucketStateAgent SkillsPython support
OverviewRuntimeGatewayMemoryBrowserCode InterpreterDev Mode
API Gateway Proxy
OverviewGeneral ConfigurationAuthenticationAPI KeysData SourcesResolversPipeline FunctionsSubstitutionsCachingDelta SyncCustom DomainWAFCLI Commands
Deploying SAM/CFN TemplatesWorkflow Tips
OverviewCreating PluginsCLI OutputCustom CommandsCustom VariablesExtending the Configuration schemaExtending and overriding configuration
OverviewDashboardAxiom
Overviewagent docsagent inspectagent setupagent skills installagent skills list / readdeploydeploy functiondeploy listdevdiffinfoinvokeinvoke localloginlogin awslogin aws ssologsmetricspackageplugin installplugin uninstallprintprunereconcileremoverollbackrollback functionusage
OverviewConcepts
OverviewMetricsTracesTroubleshoot
OverviewNode.jsPython
OutputsProviders
OverviewBranch DeploymentsPreview DeploymentsCustom ScriptsTestingPrivate PackagesNotificationsMono ReposDeploy in your own CI/CDBest PracticesTroubleshootingFAQ
OverviewSetupToolsAWS Integration
Serverless.yml Reference
Examples and TutorialsConfiguration Validation
  1. Usage
  2. Events
  3. Schedule

Schedule Events

The schedule event runs a Lambda function on a schedule, written as a rate(...) or cron(...) expression. By default, the Framework creates an Amazon EventBridge scheduled rule on the default event bus; with method: scheduler, it creates an EventBridge Scheduler schedule instead, which adds time zones and a higher quota.

This serverless.yml runs crawl every 2 hours, and also every day at 12:00 UTC:

# serverless.yml
service: my-service

provider:
  name: aws
  runtime: nodejs24.x

functions:
  crawl:
    handler: handler.crawl
    events:
      - schedule: rate(2 hours)
      - schedule: cron(0 12 * * ? *)

On a scheduled rule, the handler receives an EventBridge Scheduled Event:

// handler.mjs
export const crawl = async (event) => {
  console.log(event['detail-type'], event.time)
}

A function can have several schedule events, and each one creates its own rule or schedule.

Rate and cron expressions

The schedule event takes a rate or a cron expression:

  • rate(value unit): value is a positive integer and unit is minute, hour or day for a value of 1, and minutes, hours or days for larger values: rate(1 hour), rate(5 minutes).
  • cron(minutes hours day-of-month month day-of-week year): six fields, and one of day-of-month and day-of-week is ?: cron(0 12 * * ? *), cron(0 0/4 ? * MON-FRI *).

Scheduled rules evaluate cron expressions in UTC. To run on a local time, use EventBridge Scheduler with a timezone; see Use EventBridge Scheduler. For the full syntax, see Schedule expressions for rules.

To set other options, use the object form, with the expression in rate. rate also takes a list of expressions, which creates one rule or schedule per expression with the same settings. This function runs at different times on weekdays and on weekends, with the same input:

functions:
  report:
    handler: handler.report
    events:
      - schedule:
          rate:
            - cron(0 0/4 ? * MON-FRI *)
            - cron(0 2 ? * SAT-SUN *)
          input:
            key1: value1
            key2: value2

Pass input to the function

By default, the function receives the scheduled event. The schedule event takes one of three keys to change it:

  • input: an object, or a JSON string of up to 8,192 characters, passed to the function instead of the event. When the object has a body key whose value is a JSON string, the Framework parses that string, so the function receives body as an object.
  • inputPath: a JSONPath into the scheduled event, up to 256 characters; the function receives that part of it.
  • inputTransformer: inputPathsMap maps names to JSONPaths in the event, and inputTemplate (required, up to 8,192 characters) builds the input from them.

EventBridge accepts one of them per target, so set only one per schedule event. Each event in this example uses one of them:

functions:
  aggregate:
    handler: handler.aggregate
    events:
      - schedule:
          rate: rate(10 minutes)
          input:
            key1: value1
            stageParams:
              stage: dev
      - schedule:
          rate: cron(0 12 * * ? *)
          inputPath: '$.detail'
      - schedule:
          rate: rate(2 hours)
          inputTransformer:
            inputPathsMap:
              eventTime: '$.time'
            inputTemplate: '{"time": <eventTime>, "key1": "value1"}'

With method: scheduler, only input is available; inputPath and inputTransformer stop packaging.

Name, description and state

The schedule event's name and description set the rule's or schedule's name and description, and enabled: false creates it disabled:

functions:
  aggregate:
    handler: handler.aggregate
    events:
      - schedule:
          name: my-service-${sls:stage}-aggregate
          description: Aggregates statistics every 2 hours
          rate: rate(2 hours)
          enabled: false
  • name: up to 64 letters, digits, ., - and _. Without it, CloudFormation generates a name. name can't be set when rate lists more than one expression. Names are unique per account and Region, so include the stage to deploy several stages to one Region.
  • description: up to 512 characters.
  • enabled: default true.

Use EventBridge Scheduler

Set the schedule event's method to scheduler to create an AWS::Scheduler::Schedule instead of an AWS::Events::Rule. EventBridge Scheduler evaluates cron expressions in the time zone set in timezone:

functions:
  report:
    handler: handler.report
    events:
      - schedule:
          method: scheduler
          rate: cron(0 9 ? * MON-FRI *)
          timezone: America/New_York
          input:
            key1: value1
  • method: eventBus (the default) or scheduler. Changing it replaces the rule with a schedule, or the reverse, on the next deploy.
  • timezone: an IANA time zone name, such as America/New_York. It is accepted only with method: scheduler; without it, Scheduler uses UTC.
  • With scheduler, the schedule event takes input, name, description and enabled, but not inputPath or inputTransformer. The schedule goes in the account's default schedule group, with no flexible time window.

Scheduled rules count against EventBridge's default quota of 300 rules per event bus in each account and Region (100 in some Regions), and they always go on the default bus. EventBridge Scheduler has a default quota of 10,000,000 schedules per Region. See EventBridge quotas and EventBridge Scheduler quotas.

Permissions for schedule events

With method: eventBus, the Framework adds an AWS::Lambda::Permission that lets events.amazonaws.com invoke the function, limited to the rule's ARN.

With method: scheduler, EventBridge Scheduler invokes the function with the function's execution role. The Framework adds scheduler.amazonaws.com to the role's trust policy and lambda:InvokeFunction on the function, its versions and aliases to the role's policy. When the function uses a role of your own, set in provider.iam.role as an ARN or in the function's role, add both to that role. See Set up the execution role.

schedule event options

The schedule event takes an expression string, or an object with these keys:

KeyTypeDefaultAllowed values
rateString or list of stringsRequiredrate(...) or cron(...) expressions
methodStringeventBuseventBus, scheduler
enabledBooleantruetrue, false
nameStringGenerated by CloudFormationUp to 64 letters, digits, ., -, _; one rate expression only
descriptionStringNot setUp to 512 characters
inputObject or JSON stringNot set (the scheduled event)A string of up to 8,192 characters
inputPathStringNot setA JSONPath of up to 256 characters; eventBus only
inputTransformerObjectNot setinputTemplate (required) and inputPathsMap; eventBus only
timezoneStringNot set (UTC)An IANA time zone name; scheduler only

Related

  • EventBridge events, for schedules defined with the eventBridge event
  • serverless.yml reference: Schedule
  • EventBridge Scheduler schedule types
Edit this page
Prev S3NextSNS

Contents

  • Schedule Events
  • Rate and cron expressions
  • Pass input to the function
  • Name, description and state
  • Use EventBridge Scheduler
  • Permissions for schedule events
  • schedule event options
  • Related

Related

GuidesPluginsExamplesSlack CommunitySupport