Last active
February 19, 2021 18:36
-
-
Save deegloo/622b1065451d8a482cdb601f278245da to your computer and use it in GitHub Desktop.
Scheduling AWS Lambda execution using CloudWatch event rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: >- | |
Schedule - the infrastructure. | |
AWSTemplateFormatVersion: 2010-09-09 | |
Transform: "AWS::Serverless-2016-10-31" | |
Resources: | |
NotifierLambda: | |
Type: AWS::Serverless::Function | |
Properties: | |
FunctionName: 'notifier' | |
Handler: index.handler | |
CodeUri: 's3://deegloo-blog-post/schedule-notify-trigger/notifier-partial.zip' | |
Runtime: nodejs6.10 | |
MemorySize: 1536 | |
Timeout: 300 | |
Environment: | |
Variables: | |
SOME_VARIABLE: 'some-value' | |
NotifierLambdaScheduledRule: | |
Type: AWS::Events::Rule | |
Properties: | |
Name: 'notifier-scheduled-rule' | |
Description: 'Triggers notifier lambda once per day' | |
ScheduleExpression: cron(0 7 ? * * *) | |
State: ENABLED | |
Targets: | |
- | |
Arn: !GetAtt NotifierLambda.Arn | |
Id: TargetFunctionV1 | |
NotifierLambdaInvokePermission: | |
Type: AWS::Lambda::Permission | |
Properties: | |
FunctionName: !Ref NotifierLambda | |
Action: lambda:InvokeFunction | |
Principal: events.amazonaws.com | |
SourceArn: !GetAtt NotifierLambdaScheduledRule.Arn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment