Amplify PubSub without cognito

0

I have a simple react app running on fargate that uses pubsub to publish/subscribe to mqtt topics in iot core. I am using cognito for permissions as described in the docs. https://docs.amplify.aws/lib/pubsub/getting-started/q/platform/js/

I'd like to set something up that instead uses the iam role of the container. Is this possible with amplify pubusb? If not, what alternative would you recommend?

I've looked into the v3 javascript sdk a bit, but I'm having trouble figuring out how to publish/subscribe to topics, and to be honest am not even sure if the javascript sdk is meant for what I want to do.

已提問 2 年前檢視次數 228 次
1 個回答
0

Hi rujoesmith. Apologies that you didn't get an answer sooner after asking.

The AWS SDK JS V3 is for the HTTP APIs. It's not possible to subscribe over HTTP. Thus the IoT Data Plane API only has a publish operation.

More information about AWS IoT protocol options here: https://docs.aws.amazon.com/iot/latest/developerguide/protocols.html

One alternative to Amplify pubsub is to use the AWS IoT Device SDK. JS V2 in this case: https://github.com/aws/aws-iot-device-sdk-js-v2

You can use the device SDK to connect to the MQTT broker over websocket: https://github.com/aws/aws-iot-device-sdk-js-v2/blob/main/samples/node/websocket_connect/index.ts

profile pictureAWS
專家
Greg_B
已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南