我正在尝试在我的覆盆子pi上设置一个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 localhost,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));
}
});
答案 0 :(得分:1)
也许
"您需要更改应用程序中的端点才能使用 Amazon DynamoDB服务。"
AWS.config.update({endpoint: "https://dynamodb.us-west-2.amazonaws.com"});