0

I am trying to create a scheduled lambda function using the Serverless framework and to send it different parameters from different events.

here is my serverless configuration:

functions:
  profile:
    timeout: 10
    handler: profile.profile
    events:
      - schedule:
          rate: rate(1 minute)
          params:
            hello: world

The issue is that when I run sls deploy, I get the following error:

Serverless:   at 'functions.profile.events[0]': unrecognized property 'params'

This is basically copied from the documentation here, so should work...

Am I missing something?

Tomer Amir
  • 1,515
  • 4
  • 27
  • 54

3 Answers3

3

The documentation you're referencing is for Apache Open Whisk.

If you're using AWS, you'll need to use input as shown in the aws documentation

functions:
  aggregate:
    handler: statistics.handler
    events:
      - schedule:
          rate: rate(10 minutes)
          enabled: false
          input:
            key1: value1
            key2: value2
            stageParams:
              stage: dev
Aaron Stuyvenberg
  • 3,437
  • 1
  • 9
  • 21
1

The documentation that you referred to is for OpenWhisk https://www.serverless.com/framework/docs/providers/openwhisk/events/schedule/#schedule/.

Cloudwatch Events (now rebranded as EventBridge) is at https://www.serverless.com/framework/docs/providers/aws/events/schedule/#enabling--disabling. Sample code for reference

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

Official docs at https://docs.aws.amazon.com/eventbridge/latest/userguide/scheduled-events.html

blr
  • 908
  • 4
  • 8
0

I could see one of my configuration something like below. There we use parameters instead of param.

functions:
  test_function:
    handler: handler.test_function
    memorySize: 512
    timeout: 60
    events:
      - http:
          path: get-hello
          method: get
          request:
            parameters:
              queryStrings:
                name: true
J.P
  • 495
  • 1
  • 6
  • 15