matwerber1 / aws-amplify-react-toolkit

An Amplify+React project that contains some "widgets" to demo/experiment with AWS.
11 stars 3 forks source link

Issue with IOT Message Viewer #3

Closed gannaramu closed 3 years ago

gannaramu commented 3 years ago

I cant get the IOT Message Viewer to work. I also tried your previous repository aws-amplify-react-iot-pub-sub-demo but I had no luck there too. Could you please give me few pointers on where I could have been doing wrong?

Thank you for your help Ram Rohit

matwerber1 commented 3 years ago

Hi,

First, are any of the other widgets working? e.g. can you use the EC2 instance viewer?

Log output In your browser, can you open the Developer Tools console, then click the subscribe and publish buttons on the widget and share the output? Are any errors appearing?

Example:

image

Cognito admin group This project deploys a Cognito user group named "admin". Log in to the AWS console, go to your Cognito User Pool, and make sure that your Cognito user has been added to the admin group. This group gives *.* permissions via Cognito Federated Identities.

Attached IoT policy Can you confirm that the IoT policy created by the project is being attached to your Cognito user's federated identity ID?

pubsub-config.js

Confirm that you're using the correct AWS IoT endpoint and region for your account. The region should be the same region that you launched your Amplify project in.

We can set up a screenshare sometime and try to troubleshoot, if you like.

gannaramu commented 3 years ago

I was previously testing the webpage on aws amplify and not locally. Today when I tried to run it locally with npm run start I get this Issue. Looks like issue with the policy. could you help me debug this?

image

gannaramu commented 3 years ago

Looks like the project doesn't automatically create the IOT policy but could you help help on how to check if that policy is attached to the federated identity ID? it currently looks like this:

// Initialize the Amazon Cognito credentials provider
CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(
    getApplicationContext(),
    "us-east-1:419a895a-f027-4ac6-9472-9793e330aa75", // Identity pool ID
    Regions.US_EAST_1 // Region
);
matwerber1 commented 3 years ago

Hi - I modified the Amplify project to create an IoT Policy named amplify-toolkit-iot-message-viewer and automatically attach the policy to the logged-in user. The pubsub-config.js has been removed as well, as the widget now automatically determines the proper endpoint (it will use the same region as the Amplify project). Can you pull the new changes and run amplify push (or if easier, just delete the old project and recreate with the new code)? I think this will solve issues.

gannaramu commented 3 years ago

This one worked like a charm! Thank you for your time Mat!

matwerber1 commented 3 years ago

great to hear! thank you for your feedback :)