Iot.searchIndex works fine from CLI, but not from Lambda

0

Having trouble here. Search index works just fine from CLI, but then fails from Lambda...

$ aws iot search-index --index-name "AWS_Things" --query-string "thingName:myThingName"
{
    "things": [ (normal response)]
}

and yet

var params = {
    queryString: "thingName:" + data.Item.thingName,
    indexName: 'AWS_Things'
};
iot.searchIndex(params, function(err, data) {
    if (err) {
        console.log("error from iot.searchIndex");
        console.log(err, err.stack); // an error occurred
    } else {
        console.log("success from iot.searchIndex");
        console.log(data); // successful response
    }
});

The latter produces the error

02:09:20
2019-11-05T02:09:20.595Z 38957129-0e04-43b2-acf6-8b67da6e7ce0 INFO error from iot.searchIndex
02:09:20
2019-11-05T02:09:20.595Z 38957129-0e04-43b2-acf6-8b67da6e7ce0 INFO { ResourceNotFoundException: Not Found at Object.extractError 

What gives? I'm providing the exact information in both places, as verified by console logging, etc. One works, one doesn't. And both users have full IOT access permissions. I don't get it. Any help would be greatly appreciated.

Cyrus
質問済み 5年前279ビュー
2回答
0

Figured it out. I had copied my iot declaration from iotdata with an endpoint. Commenting it out fixed things.

var iotdata = new AWS.IotData({
    endpoint: 'asdfasd-ats.iot.us-east-1.amazonaws.com',
    apiVersion: '2015-05-28'
});

var iot = new AWS.Iot({
 //   endpoint: 'asdfasd-ats.iot.us-east-1.amazonaws.com',
    apiVersion: "2015-05-28"
});
Cyrus
回答済み 5年前
0

Hi Cyrus, glad you got it working. Adding a point of clarification for future readers. API calls to the message broker (pub/sub, shadow; also called the 'data plane') use the custom endpoint and this needs specifying in the AWS.IotData client. Most other APIs are on the control plane, packaged in the AWS.Iot client, and these use a default API endpoint for all customers like iot.us-east-1.amazonaws.com.

AWS
Ryan_B
回答済み 5年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ