Here my scenario I try to cover this time.
- Raise an event based on a cron pattern
- Subscribe to that event with a Lambda
As picture this would look like this:
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:
Here is the overall CloudFormation template:
- Implementing DynamoDB triggers (streams) using CloudFormation
- Using parameters through multiple nested CloudFormation stacks
- Integrate API Gateway with SNS using CloudFormation
- Integrate API Gateway with Kinesis Firehose using CloudFormation
- visualizing a cloudformation template
- extending cloudformation with custom resources
- hosting a Cloudfront site with S3 and API Gateway
- Publish an S3 Event to Lambda through SNS