I use a CloudFormation template as project definition for this task.
So here is my YAML explained step-by-step (whole YAML is attached at the bottom).
I copied the header from an existing template since I have nothing to add here:
First I create a role, which is a requirement for a lambda function. Since I only implement a dummy lambda, my role has no policies attached.
After that, I can create the lambda function that I want to run in case of an triggered event.
Now I can define the event, that should trigger my function.
A little heads up regarding the cron pattern. This is not a standard linux cron pattern, Amazon used some variation and it does produce error if you paste in linux cron patterns. So if you can, I would suggest using the rate expression instead.
e.g. if you want your code to run every 15 minutes, you can implement that either way:
rate expression: rate(15 minutes)
cron expression: cron(0/15 * * * ? *)
At last, we need to define a permission, so that the event is actually allowed to invoke the lambda.
To instantiate this template, just download the file and run the following command: