MCPcopy Create free account
hub / github.com/aws-samples/aws-cdk-examples / LambdaCronStack

Class LambdaCronStack

python/lambda-cron/app.py:9–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8
9class LambdaCronStack(Stack):
10 def __init__(self, app: App, id: str) -> None:
11 super().__init__(app, id)
12
13 with open("lambda-handler.py", encoding="utf8") as fp:
14 handler_code = fp.read()
15
16 lambdaFn = lambda_.Function(
17 self, "Singleton",
18 code=lambda_.InlineCode(handler_code),
19 handler="index.main",
20 timeout=Duration.seconds(300),
21 runtime=lambda_.Runtime.PYTHON_3_12,
22 )
23
24 # Run every day at 6PM UTC
25 # See https://docs.aws.amazon.com/lambda/latest/dg/tutorial-scheduled-events-schedule-expressions.html
26 rule = events.Rule(
27 self, "Rule",
28 schedule=events.Schedule.cron(
29 minute='0',
30 hour='18',
31 month='*',
32 week_day='MON-FRI',
33 year='*'),
34 )
35 rule.add_target(targets.LambdaFunction(lambdaFn))
36
37
38app = App()

Callers 2

app.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected