Carova
Serverless AWS Lambdafunction Scheduled Cronjob
Use the Serverless Framework to deploy a scheduled cronjob Lambdafunction to Amazon Web Service. The scheduled Lambdafunction in the template below will run every 10 minutes.
AWS Scheduled Lambdafunction Serverless Template
1functions:
2 CustomLambdaName:
3 handler: src/scheduled/index.handler
4 environment:
5 PRIMARY_KEY: ID
6 events:
7 - schedule:
8 rate: rate(10 minutes)
9 enabled: true
10 iamRoleStatements:
11 - Effect: Allow
12 Action:
13 - dynamodb:Query
14 Resource:
15 - ${cf:cross-stack-reference-${opt:stage, self:provider.stage}.DynamoDBTableName}/index/date-index
16 - Effect: Allow
17 Action:
18 - dynamodb:DeleteItem
19 - dynamodb:PutItem
20 - dynamodb:UpdateItem
21 Resource:
22 - ${cf:cross-stack-reference-${opt:stage, self:provider.stage}.DynamoDBTableName}
23 iamRoleStatementsInherit: true