0
votes

I am trying to create a dynamic policy for AWS IOT.

I am making a connection to IOT successfully with an open iot policy using MQTT Over the WebSocket Protocol as seen here: https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html

Here is what a policy variable is: https://docs.aws.amazon.com/iot/latest/developerguide/policy-variables.html

What is the value of iot:ClientId in the IOT policy, when a connection is made? Remember I am connected to the client correctly with cognito session token, etc. Or, Is there a way I can test these policies in realtime to see what the value of iot:ClientId is?

Here is more or less how I am creating a client.

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' ]);
});
1

1 Answers

1
votes

The value of iot:ClientId is the client Id you specify when creating the mqtt connection.

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