-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathlambda_handler_scheduled.py
More file actions
35 lines (28 loc) · 962 Bytes
/
lambda_handler_scheduled.py
File metadata and controls
35 lines (28 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""
Purpose
Shows how to implement an AWS Lambda function that handles invocation from
Amazon EventBridge.
"""
import calendar
import logging
import dateutil.parser
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
"""
Logs the call with a friendly message and the full event data.
:param event: The event dict that contains the parameters sent when the function
is invoked.
:param context: The context in which the function is called.
:return: The result of the specified action.
"""
if "time" in event:
dt = dateutil.parser.parse(event["time"])
logger.info(
"Thanks for calling me on %s at %s.",
calendar.day_name[dt.weekday()],
dt.time().isoformat(),
)
logger.info("Full event: %s", event)