-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
33 lines (29 loc) · 782 Bytes
/
hello.py
File metadata and controls
33 lines (29 loc) · 782 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
import json
import logging
import os
import boto3
logger = logging.getLogger()
logger.setLevel(logging.INFO)
LAMBDA_FUNCTION_NAME = os.getenv("CAT_LAMBDA")
client = boto3.client('lambda')
def lambda_handler(event, context):
try:
response = client.invoke(
FunctionName = LAMBDA_FUNCTION_NAME,
InvocationType = 'RequestResponse'
)
fact = json.load(response['Payload']).get("fact")
logger.info(str(fact))
except Exception as e:
logger.error(str(e))
fact = None
return {
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"body": json.dumps({
"message": "Traditional Hello world",
"fact" : fact
})
}