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 Antworten
1
Akzeptierte Antwort

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
beantwortet vor 2 Jahren
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
EXPERTE
beantwortet vor 2 Jahren
  • if it is an anti-pattern, why is this implementation still available and why has its use not been withdrawn as a bad practice?

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen