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개 답변
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?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠