lambda post messages in mqtt iot core

0

Hey,

Quite new here and im looking for an solution. Currently i've created a python script and uploaded to aws lambda function. The code gathers data from an external api and stores it into a dynamodb database. This part works fine. For part 2 i would like to post this data into an MQTT broker like IoT core where my external IoT device can subscribe to and read incomming messages. I couldn't find any solution/documentation about this topic so i hope someone can explain me or help me out.

질문됨 한 달 전184회 조회
2개 답변
2
수락된 답변

Hi! There are a couple approaches you can take. If the Lambda just needs to publish a message, you can POST via HTTPS. Grant the Lambda function's IAM role the iot:Publish action, and use HTTP on port 443 as noted here using Signature v4.

If the Lambda also requires to subscribe to an MQTT topic, then an X.509 certificate for mTLS or an MQTT over WebSocket connection can be used.

No changes needed on the devices subscribing to the topic.

AWS
Gavin_A
답변함 한 달 전
  • It should only post message to the broker which the exenternal IoT devices could subscribe on. So i need to add this in my code ? or create a new thing in IoT Core?

  • No need to create a Thing, certificate, or IoT policy in IoT Core in that case. The only IAM resource needed is iot:Publish. Here is an example of doing this in boto3 (Python) and Node.js. And Rust example too. If you could accept the answer if this does address your question, much appreciated.

0

The simplest approach is to then trigger another lambda function in response to dynamo streams:

https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#

You could also into eventbridge pipes. Your source will be the stream and your target could any of those: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-pipes-event-target.html

profile picture
전문가
답변함 한 달 전

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

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

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

관련 콘텐츠