I have been trying to deploy a Lambda in Serverless to run on a Cron schedule that invokes it every hour. When it is invoked, I want the event inside the Lambda to be populated by my own JSON input rather than the info from the Cron event which is the default input when it is deployed.
Inside the AWS Console, I am able to manually go into the Cron trigger for the Lambda and change the input from "Matched event" to "Constant (JSON text)" in order to get the result that I want. Since Serverless creates this rule while deploying the Lambda, I feel like there should be some way of changing the input through a configuration in the serverless.yml file. I haven't been able to find anything while searching through the docs for Serverless, so now I'm wondering if this is possible through Serverless in its current state, and if so how to go about it.
Any advice would be appreciated.
Edit: There was an update that should have added this functionality, however I still have not been able to deploy with a schedule with JSON using Serverless 1.3.0 (and have also tested with 1.2.0). Some examples of the serverless.yml I used are below:
functions:
test:
handler: test.test
description: "test serverless Lambda"
memorySize: 128
timeout: 300
events:
- schedule:
rate: rate(10 minutes)
input:
key: value
- schedule:
rate: rate(10 minutes)
input: '{"key": "value"}'
- schedule:
rate: rate(10 minutes)
input:
key: 'value'
Would anybody be able to comment on the state of this feature in Serverless as of 1.3.0, and whether or not my serverless.yml above looks fine?
Edit 2: Posting the working serverless.yml
functions:
test:
handler: test.test
description: "test serverless Lambda"
memorySize: 128
timeout: 300
events:
- schedule:
rate: rate(10 minutes)
enabled: true
input:
key: value
- schedule:
rate: rate(10 minutes)
input: '{"key": "value"}'
enabled: true
- schedule:
rate: rate(10 minutes)
input:
key: 'value'
enabled: true