I already have my lambda / roles defined in cloudformation and would love to also use it to add a scheduled eventsources ... are there any docs or examples around ?
AWS CloudFormation invokes your Lambda function asynchronously with an event that includes a callback URL. The function is responsible for returning a response to the callback URL that indicates success or failure. For the full response syntax, see Custom resource response objects.
All in all, CloudFormation makes deploying AWS Lambda functions incredibly simple. Start by creating the template file that will define your resources. This will be your working folder for your code. Next, create your function in the appropriate file for your desired Lambda runtime.
Use Aws::Event::Rule with a ScheduleExpression
and a AWS::Lambda::Permission
// rule to periodically call the lambda "TagWatcherRule": { "Type": "AWS::Events::Rule", "Properties": { "ScheduleExpression": "rate(10 minutes)", "Targets": [ { "Id": "TagWatcherScheduler", "Arn": { "Fn::GetAtt": [ "TagWatcherFunction", "Arn" ] } } ] } }, // role may call the lambda "InvokeLambdaPermission": { "Type": "AWS::Lambda::Permission", "Properties": { "FunctionName": { "Fn::GetAtt": [ "TagWatcherFunction", "Arn" ] }, "Action": "lambda:InvokeFunction", "Principal": "events.amazonaws.com", "SourceArn": { "Fn::GetAtt": [ "TagWatcherRule", "Arn" ] } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With