【问题标题】:When using Cognito, and creating a policy for AWS IOT, What is the value of the iot:ClientId policy variable?使用 Cognito 并为 AWS IOT 创建策略时,iot:ClientId 策略变量的值是多少?
【发布时间】:2023-03-30 02:18:02
【问题描述】:

我正在尝试为 AWS IOT 创建动态策略。

我正在使用开放式物联网策略成功连接到物联网 基于 WebSocket 协议的 MQTT 如此处所示: https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html

以下是策略变量: https://docs.aws.amazon.com/iot/latest/developerguide/policy-variables.html

当建立连接时,IOT 策略中 iot:ClientId 的值是多少? 请记住,我已使用 cognito 会话令牌等正确连接到客户端。 或者,有没有一种方法可以让我实时测试这些策略以查看 iot:ClientId 的值是多少?

这或多或少是我创建客户端的方式。

let client = new MqttClient(() => {
    const url = v4.createPresignedURL(
        'GET',
        AWS_IOT_ENDPOINT_HOST.toLowerCase(),
        '/mqtt',
        'iotdevicegateway',
        crypto.createHash('sha256').update('', 'utf8').digest('hex'),
        {
            'key': AWS_ACCESS_KEY,
            'secret': AWS_SECRET_ACCESS_KEY,
            'protocol': 'wss',
            'expires': 15
        }
    );

    return websocket(url, [ 'mqttv3.1' ]);
});

【问题讨论】:

    标签: javascript node.js amazon-web-services mqtt aws-iot


    【解决方案1】:

    iot:ClientId的值是你创建mqtt连接时指定的客户端Id。

    https://docs.aws.amazon.com/iot/latest/developerguide/basic-policy-variables.html

    【讨论】:

    • 感谢您提供此文档。我不知道我是怎么错过的。我只需要在建立 MQTT 客户端时设置客户端 ID。
    猜你喜欢
    • 2020-06-30
    • 2018-02-27
    • 1970-01-01
    • 1970-01-01
    • 2018-04-22
    • 1970-01-01
    • 1970-01-01
    • 2018-04-13
    • 1970-01-01
    相关资源
    最近更新 更多