Sync between publish and subscribe to iot topic in AWS Lambda

0

Hi folks, Hope you are well and safe and also hope that this questions don't gonna be an already asked question.

I'm here to ask a brief explanation on how can I write in AWS Lambda function a sync mechanism. I mean: I'm writing a .py script that, when is triggered, publish a message to a topic. When the IoT things receive the message on published on this topic, react publishing response on another topic. Well, at this point, I want to receive the published message from IoT thing in same lambda function that was firstly triggered from outside. Is it possible or I need to use AWS IoT rules in order to trigger a different AWS Lambda function?

Best regards.

1개 답변
1

If by "same lambda function" you mean the same invokation of a function, then no. But you could trigger a different invokation of the same function for this different purpose. Usually though you would trigger a different function for better code structure and least-privilege security configuration. Either way it sounds like you might want to share state between invokations - DynamoDB is a common way to do it.

전문가
답변함 2년 전
  • Thanks @skinsman.

    Yes, trigger different invokation of the same function seems the solution. The next problem, in this approach, could be: how can I hold the context that invoke firstly the Lambda function in order to give a response to it when I receive the second trigger?

    I mean, how can I keep the http connection alive, and reuse after second trigger?

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

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

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

관련 콘텐츠