I'm trying to get details of the registered things and create new things. I get ResourceNotFoundException for both of them.
var AWS = require('aws-sdk');
var iot = new AWS.Iot({
endpoint: "https://XXXXXXXXXX.iot.us-east-1.amazonaws.com",
region: "us-east-1",
accessKeyId: "XXXXXXXXXX",
secretAccessKey: "XXXXXXXXXX"
});
var params = {
thingName: 'D02',
attributePayload: {
attributes: {
'Org': 'Org2'
},
merge: false
},
thingTypeName: 'thing1'
};
iot.createThing(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
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 attached AWSIoTFullAccess permission.
Is there anything wrong here? What could be the reason for this?
Got it sorted out.
It was giving 404 or raising ResourceNotFoundException because endpoint was incorrect. IoT constructor would have to be like this. Endpoint should be just iot.us-east-1.amazonaws.com.
var iot = new AWS.Iot({
endpoint: "iot.us-east-1.amazonaws.com",
region: "us-east-1",
accessKeyId: "XXXXXXXXXX",
secretAccessKey: "XXXXXXXXXX"
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With