Skip to content

Instantly share code, notes, and snippets.

@freenerd
Created February 4, 2015 10:38
Show Gist options
  • Save freenerd/8f59f7baff60ee0125d0 to your computer and use it in GitHub Desktop.
Save freenerd/8f59f7baff60ee0125d0 to your computer and use it in GitHub Desktop.
Sum up provisioned write and read capacity for DynamoDB tables in a region
// to install
// brew install node
// npm install aws-sdk queue-async
// to run
// fill your shell with aws credentials http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
// node dynamo-capacity.js
var AWS = require('aws-sdk');
var queue = require('queue-async');
var dynamodb = new AWS.DynamoDB({region: "us-east-1"});
var sums = {
writes: 0,
reads: 0
};
var q = queue();
dynamodb.listTables({Limit: 100}, function(err, data) {
if (err) throw err;
data.TableNames.forEach(function(table) {
q.defer(function(cb) {
dynamodb.describeTable({TableName: table}, function(err, data) {
if (err) throw err;
sums.reads += data.Table.ProvisionedThroughput.ReadCapacityUnits;
sums.writes += data.Table.ProvisionedThroughput.WriteCapacityUnits;
cb();
});
});
});
q.awaitAll(function() {
console.log("Provisioned Write Capacity:", sums.writes);
console.log("Provisioned Read Capacity: ", sums.reads);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment