Bill Huang
Bill Huang

Reputation: 89

Setting up DynamoDB table on raspberry pi

I am trying to set up a dynamodb table on my raspberry pi but am running into a strange network issue.

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"
}

I am able to ping localhost and the pi is connected to wifi. Does anyone have any idea what is going on? Below is the code I am using to create the table. Thank you very much.

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));
    }
});

Upvotes: 2

Views: 853

Answers (1)

hB0
hB0

Reputation: 2037

Perhaps

"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"});

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

Upvotes: 1

Related Questions