LoginSignup
0
0

More than 5 years have passed since last update.

DynamodbLocalでScanを実行するとCannot do operations on a non-existent tableになってしまう問題を解消する

Last updated at Posted at 2016-09-27

概要

DynamodbLocalで開発しているとき、ふとSacnが正しく動作しないことに気づきました。
で、その対応を調べたのでメモっておきます。

やったこと

dynamodb.listTables().eachPage(function(err, data) {
    if (err) {
        ppJson(err); // an error occurred
    } else if (data) {
        ppJson(data);
    }
});

でテーブル一覧をだして、テーブル名を間違えないようにメモ(コピーできないの辛い)、Scanで一覧出し。

var params = {
    TableName: 'test_RECORD_A',
};
docClient.scan(params, function(err, data) {
    if (err) ppJson(err); // an error occurred
    else ppJson(data); // successful response
});

結果、

"message":"Cannot do operations on a non-existent table"
"code":"ResourceNotFoundException"
"time":"2016-09-27T06:55:28.448Z"
"statusCode":400
"retryable":false

ええ・・・

やり方

を参考にして、少し付け加えてみました。

AWS.config.update({
  region: "us-west-2",
  endpoint: "http://localhost:8000"
});

var docClient = new AWS.DynamoDB.DocumentClient();

var params = {
    TableName: 'test_RECORD_A',
};
docClient.scan(params, function(err, data) {
    if (err) ppJson(err); // an error occurred
    else ppJson(data); // successful response
});

すると、うまく動きました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0