javascript - 在树莓派上设置 DynamoDB 表

标签 javascript raspberry-pi amazon-dynamodb

我正尝试在我的树莓派上设置一个 dynamodb 表,但遇到了一个奇怪的网络问题。

pi@raspberrypi:~/Casty/InitDynamoDB $ node CreateMovieListTable.js 
Adding a new item...
Unable to add item. Error JSON: {
    "message": "connect ECONNREFUSED",
    "code": "NetworkingError",
    "errno": "ECONNREFUSED",
    "syscall": "connect",
    "region": "us-west-2",
    "hostname": "localhost",
    "retryable": true,
    "time": "2016-07-03T00:18:18.983Z"
}

我能够 ping 本地主机并且 pi 已连接到 wifi。有谁知道发生了什么事?下面是我用来创建表格的代码。非常感谢。

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

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

var dynamodb = new AWS.DynamoDB();

var params = {
    TableName : "MovieList",
    KeySchema: [
        { AttributeName: "year", KeyType: "HASH"},  //Partition key
        { AttributeName: "title", KeyType: "RANGE" }  //Sort key
    ],
    AttributeDefinitions: [
        { AttributeName: "year", AttributeType: "N" },
        { AttributeName: "title", AttributeType: "S" }
    ],
    ProvisionedThroughput: {
        ReadCapacityUnits: 10,
        WriteCapacityUnits: 10
    }
};

dynamodb.createTable(params, function(err, data) {
    if (err) {
        console.error("Unable to create table. Error JSON:", JSON.stringify(err, null, 2));
    } else {
        console.log("Created table. Table description JSON:", JSON.stringify(data, null, 2));
    }
});

最佳答案

也许

"You need to change the endpoint in your application in order to use the Amazon DynamoDB service."

AWS.config.update({endpoint: "https://dynamodb.us-west-2.amazonaws.com"});

引用:http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.NodeJs.Summary.html

关于javascript - 在树莓派上设置 DynamoDB 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38165658/

相关文章:

javascript - 使用 puppeteer 在页面中基于文本的值搜索中使用正则表达式

javascript - 使用断言 Expect(xhr.requestBody.test).to.not.exist 运行 cypress 测试用例,但 eslint 抛出错误

php - 将 javascript 对象映射到 MySQL 数据库中的 ID

javascript - 忽略 mousedown 事件上的滚动条

ffmpeg - 如何根据触发器缓冲和捕获 RTSP 流到磁盘?

conditional - 有条件更新的 DynamoDBContext

python - 树莓派与Python

go - 为什么我的交叉编译的 CGO 二进制文件不能在 Raspberry Pi (Raspbian) 上运行?

node.js - 仅使用插入配置 DynamoDB 流触发器

database - 如何获取 DynamoDB 列中的最大数量?