from chalice invoke another lambda

425 views Asked by At

HI i am using chalice to deploy rest api's flask python API

from one chalice lambda to another chalice lambda function, i am unable to perform triggering

from chalice import Chalice
import boto3
import re
import json
import config

@app.on_s3_event(bucket=config.bucket_name, events=['s3:ObjectCreated:Put'],    suffix=config.log_suffix)
def handle_s3_event(event):
"""
response = client.invoke(
FunctionName='string',
InvocationType='Event'|'RequestResponse'|'DryRun',
LogType='None'|'Tail',
ClientContext='string',
Payload=b'bytes'|file,
Qualifier='string'
)
"""
print("Received event for bucket: %s, key: %s", event.bucket, event.key)
s3_client = boto3.client('lambda')
bucket = event.bucket
key_found = re.findall(config.key, event.key) and "error" not in event.key
print("key is :", key_found)
# if key is 'systemlog' trigger one lambda ...etc
s3_client.invoke(
            FunctionName="arn:aws:lambda:us-west-2:120:function:log_file_process-dev",
            InvocationType="RequestResponse",
            Payload=json.dumps({"event_bucket": bucket, "event_key": event.key}))
print("Successfully Sent the request to Child Function.")

child function :

this is another lambda function created using Chalice

@app.route("/")
def log_reader(event_key, event_bucket):
    print("***********************************************")
    print("event_key: ", event_key)
    print("event_bucket :", event_bucket)
    print("***********************************************")

but i am unable trigger the child function

I am able to trigger the parent lambda on s3 event , but child function is not triggering from parent i have used Event/RequestResponse

0

There are 0 answers