def publishToIoTTopic()

in services/s3-new-image-event.py [0:0]


def publishToIoTTopic(payloadBody):
    topicName = os.environ['IOT_TOPIC']
    iotClient = boto3.client('iot')
    endpoint= iotClient.describe_endpoint(endpointType='iot:Data-ATS');
    endpointAddress= endpoint['endpointAddress']

    client = boto3.client('iot-data', endpoint_url='https://'+endpointAddress)
    response = client.publish(
        topic = topicName,
        qos = 0,
        payload = json.dumps(payloadBody)
    )
    return response