Aws-sdk-js: aws iot listThings returns ResourceNotFoundException

Created on 24 Aug 2017  路  3Comments  路  Source: aws/aws-sdk-js

Below is the code snippet. I get ResourceNotFoundException with status code 404. But I have several things registered in the console. Even when i try to create a new thing it gives the same error.

var AWS = require('aws-sdk');

var iot = new AWS.Iot({
    endpoint: "https://XXXXXX.iot.us-east-1.amazonaws.com",
    region: "us-east-1",
    accessKeyId: "XXXXXXXXXXXXXXXX",
    secretAccessKey: "XXXXXXXXXXXXXXXX"
});

iot.listThings({}, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else     console.log(data);           // successful response
});

As for the credentials, I created a new user in IAM. Set Programmatic access as Access Type and assigned AWSIoTFullAccess permission.

Is there anything wrong here? What is the correct method to do this?

guidance

Most helpful comment

@chrisradek I got the endpoint from the AWS IOT console in settings screen.

Got it working. Thank you very much. Set the Iot constructor like this.

var iot = new AWS.Iot({
    endpoint: "iot.us-east-1.amazonaws.com",
    region: "us-east-1",
    accessKeyId: "XXXXXXXXXXXXXXXX",
    secretAccessKey: "XXXXXXXXXXXXXXXX"
});

All 3 comments

@hashans
Where is the endpoint you're specifying coming from? I don't believe you need to specify an endpoint when using Iot, only IotData.

@chrisradek I got the endpoint from the AWS IOT console in settings screen.

Got it working. Thank you very much. Set the Iot constructor like this.

var iot = new AWS.Iot({
    endpoint: "iot.us-east-1.amazonaws.com",
    region: "us-east-1",
    accessKeyId: "XXXXXXXXXXXXXXXX",
    secretAccessKey: "XXXXXXXXXXXXXXXX"
});

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ranode picture ranode  路  4Comments

pihish picture pihish  路  4Comments

ataraxus picture ataraxus  路  4Comments

michaelwittig picture michaelwittig  路  3Comments

bhishp picture bhishp  路  4Comments