-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambda_function.py
More file actions
32 lines (21 loc) · 788 Bytes
/
Copy pathlambda_function.py
File metadata and controls
32 lines (21 loc) · 788 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
import json
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
data = {}
if isinstance(event, dict) == True:
# Get the value_1 and value_2 parameters from the event object. The
# runtime converts the event object to a Python dictionary
value_1 = event['value_1']
value_2 = event['value_2']
sum = do_sum(value_1, value_2)
print(f"The sum is {sum}")
# return the calculated sum as a JSON string
data = {"sum": sum}
else:
print(f"Não foi possível ler payload!")
logger.info(f"CloudWatch logs group: {context.log_group_name}")
return json.dumps(data)
def do_sum(value_1, value_2):
return value_1+value_2