0
votes

In the first instance I'd like to know if it's possible to publish a message to an AWS IOT MQTT topic from a lambda function? I've found the following python code that I tried but it doesn't seem to work:

import boto3
import json

client = boto3.client('iot-data', region_name='us-east-1')

# Change topic, qos and payload
response = client.publish(
        topic='mytopicname',
        qos=1,
        payload=json.dumps({"foo":"bar"})
    )

I've made sure that the policy is updated (The above was taken from this post: How can I publish to a MQTT topic in a Amazon AWS Lambda function?) but I don't seem to be getting anything published to the topic. Wonder If I'm missing something fundamental or does AWS simply not allow you to do this?

I'm not getting any errors when testing the Lambda function, Just not seeing any messages coming through on the topic.

1

1 Answers

0
votes

Sorry, this does appear to work after all.

Looks like the AWS MQTT client I was using to subscribe to the topic was not refreshing. Received the message when I reconnected the MQTT client.