Accessing cron input field within handler's code

Say I have the following function:

functions:
  hello:
    handler: handler.hello
  scrape:
    handler: handler.scrape
    timeout: 60
    events:
      - schedule:
          rate: cron(38 20 * * ? *)
          input:
            email: "true"

How do I access the field email: “true” from within the lambda’s code?

I don’t know if you can use an environmental variable such as:

functions:
  lambda:
    handler: src/handler.handler
    events:
      - schedule:
          rate: cron(38 20 * * ? *)
          input:
          email: ${self:custom.EMAIL}

custom:
   EMAIL: true

Not sure I follow, you mean your example wouldn’t work?

I’ve not tried this yet

The input properties are included in the event argument passed to your handler function:

module.exports.scrape = async (event) {
  const { email } = event
  ... do some other stuff ...
}

That’s what I was hoping and looking for but in my case event is undefined for some reason…

It’s populated only when the lambda’s trigger is Api Gateway, but not when it’s CloudWatch (cron).

Update: it’s undefined whenever I add these lines:

          input:
            email: "true"

When they’re off event is populated with data.

Hey, did you manage to solve this? I have the same question.

Hi! do you need to read the input data from a lambda?
Usually the data is inside the event object with the name you choose in the serverless file.

So if you put a “email” object will be inside the “event.email” property. Always as string.