1 Answer
- Newest
- Most votes
- Most comments
0
Hi. I can see why you might assume there is, but there's no iot-data service. You can replace all iot-data references in the policy with just iot. Then you'll be able to publish. BTW, there's no iot:Close action.
Additionally (if the Lambda is in the same account and region as the IoT Core endpoint you want to use), you don't have to explicitly set the endpoint or the region so you could reduce the code down to something like:
import boto3
import json
import logging
logger = logging.getLogger(__name__)
logger.setLevel("DEBUG")
client = boto3.client('iot-data')
def handler(event, context):
topic = "test/topic"
datum = json.dumps({"a": "b"})
logger.debug(datum)
response = client.publish(
topic=topic,
qos=0,
payload=datum,
retain=True
)
logger.debug(response)
Then you could delete the DescribeEndpoint action from the policy too. And presently, you aren't using the ListNamedShadowsForThing or AttachPolicy actions so these could be deleted too (but you probably know that).
Relevant content
- asked 5 years ago
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 3 years ago
Thank you! That did the job