如何自动化 AWS IOT 控制台进行测试?

How to automate AWS IOT console for testing?

我使用 python AWS IoT SDK 有一段时间了,但它似乎只允许通过事物进行交互。现在我想为我的物理设备编写自动测试。但是创建像“tester”这样的伪东西并让它访问测试设备主题对我来说似乎是错误的。我想要类似于 AWS IoT 控制台的东西,这样我就可以订阅和发布主题,而无需创建任何额外的东西。不幸的是,我在文档中找不到类似的东西。 有办法吗?

编辑:“我可以在没有 Things Registry 的情况下使用 AWS IoT Core 吗?”

是的,经过身份验证的设备可以与 MQTT 代理(“设备网关”)通信,而无需为物理设备提供相应的 ThingDevice Shadow

From the FAQ: Q. Do I have to use the Registry and the Device Shadow? You can have applications communicate directly to the connected devices using the Device Gateway and/or the Rules Engine in AWS IoT Core. However, we recommend using the Registry and the Device Shadow

设备可以publish(topic, payload, qos, retain=False)subscribe(topic, qos, callback=None)使用AWS IoT Device SDK for Python v2提供的mqtt.Connection对象提供的MQTT客户端。

您还可以使用 basic ingest 条消息绕过消息代理,直接发布到 IoT Core 规则(例如 $aws/rules/my-rule)。


可能会造成混淆,因为涉及多个 IoT SDK:

(1) Boto3 IoT Service: manage AWS resources. This is what you used to create your "things". It is here you would call create_topic_rule to set up a topic rule(例如 device/+/test)。

(2) Boto3 IoTDataPlane Service:“通过 HTTP (Publish) 发布消息并检索、更新和删除影子”

response = client.publish(
    topic='string',
    qos=123,
    retain=True|False,
    payload=b'bytes'|file
)

(3) AWS IoT Device SDK v2 for Python: device-side "Python bindings for the AWS IoT Device API". The repo Includes a pubsub sample 至:

send and receive messages through an MQTT connection. On startup, the device connects to the server, subscribes to a topic, and begins publishing messages to that topic. The device should receive those same messages back from the message broker, since it is subscribed to that same topic