How can we pass one Lambda function's event to another lambda?

0

I am using AWS Lambda function in AWS Connect Contact Flow. I am invoking one lambda function from another lambda function. I want to pass my Invoker lambda function's event to second lambda function. My first lambda is receiving an event from Contact Flow but I want to call the second Lambda function by passing same event. Is there any way to use same event for my second lambda function. My first lambda function's event looks like this:

{'Details': {'ContactData': {'Attributes': {}, 'Channel': 'VOICE', 'ContactId': '7417-dc-45a-8213-e6eb0c68343c', 'CustomerEndpoint': {'Address': '+187737', 'Type': 'TELEPHONE_NUMBER'}, 'CustomerId': None, 'Description': None, 'InitialContactId': '74-456a-8213-e6eb343c', 'InitiationMethod': 'OUTBOUND', 'InstanceARN': 'arn:aws:connect:eu-central-1:048600317115:instance/ba4b5110-72fd-4511321-e8b2f', 'LanguageCode': 'en-US', 'MediaStreams': {'Customer': {'Audio': None}}, 'Name': None, 'PreviousContactId': '745585577-d37c-456a-8213-e0c68343c', 'Queue': {'ARN': 'arn:aws:connect:eu-central-1:04654567115:instance/ba4b5110-72fd-451b-a94d-a5b3555552f/queue/22555551-3b99-47ed-9cab-5a026122e56e', 'Name': 'outboundQueue', 'OutboundCallerId': {'Address': '+31205555689', 'Type': 'TELEPHONE_NUMBER'}}, 'References': {}, 'SystemEndpoint': {'Address': '+31205522559', 'Type': 'TELEPHONE_NUMBER'}}, 'Parameters': {'sf_fields': 'Id, Name, account.City_CB__c', 'sf_operation': 'phoneLookup', 'sf_phone': '.+4915959595195'}}, 'Name': 'ContactFlowEvent'}

How I can call second lambda function with the same event? How I can achieve this?

已提問 2 年前檢視次數 3635 次
2 個答案
1
已接受的答案

Just put the Event as the payload into your function. Then extract the original Event from the second Lambda Event.

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html#invoke-property

AWS
Marco
已回答 2 年前
1

It is an anti-pattern to call one lambda from another lambda. Please use SQS queue or step-functions as documented here - https://docs.aws.amazon.com/lambda/latest/operatorguide/functions-calling-functions.html

profile pictureAWS
專家
已回答 2 年前
  • if it is an anti-pattern, why is this implementation still available and why has its use not been withdrawn as a bad practice?

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南