1
votes

Amazon DynamoDB has two read/write capacity modes for processing reads and writes on tables: On-demand Provisioned (default, free-tier eligible)

This is how I create provisioned table

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

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

var dynamodb = new AWS.DynamoDB();

var params = {
    TableName : "Movies",
    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));
    }
});

How I can set on-demand capacity for the table?

1
So, I just realized that you asked about on-demand capacity, not pricing. Did you mean pricing as I assumed? If you actually meant capacity, the answer is that you don't set it, so you can get rid of the capacity params. The capacity in this case is essentially unlimited. That's the beauty of on-demand billing mode.dmulter
Thanks for reply) I think your answer is correct. I just can't check it now. Yes, I need on-demand capacity, and I think turning on PAY_PER_REQUEST billing mode is a solution because when you turn on on-demand capacity in console you pay per requestmatchish

1 Answers

3
votes

You'll want to set the BillingMode as described in the AWS JavaScript SDK createTable docs. Add the following to your params:

BillingMode: 'PAY_PER_REQUEST',