Dynamo DB OnDemand Capacity

Not sure if I am missing something, but I would like to create a table, specifying the billing mode. Is there a way to override the RegisterTable to support BillingMode.

something like:

  pocoDynamo.RegisterTable<MyTable>(BillingMode.PAY_PER_REQUEST);

I’ve just added a CreateTableFilter on PocoDynamo that will let you modify the CreateTableRequest used to create the table in DynamoDB which will allow you to populate it with:

var db = new PocoDynamo(...) {
    CreateTableFilter = table => {
        if (table.TableName == nameof(MyTable))
            table.BillingMode = BillingMode.PAY_PER_REQUEST;
    }
}
.RegisterTable<MyTable>()
.InitSchema();

This change is available from the latest v5.11.1 that’s now available on MyGet.

Awsome. Thanks mythz!!!

1 Like

In the event that anyone else is using the CreateTableFilter to apply PAY_PER_REQUEST billing, you need to “nullify” the ProvisionedThroughput property, otherwise, you will get an Amazon.DynamoDBv2.AmazonDynamoDBException.

Amazon.DynamoDBv2.AmazonDynamoDBException : One or more parameter values were invalid: Neither ReadCapacityUnits nor WriteCapacityUnits can be specified when BillingMode is PAY_PER_REQUEST

To expand on mythz’s answer, you would need to do the following:

  var db = new PocoDynamo(...) {
                CreateTableFilter = table =>
                {
                    if (table.TableName == nameof(MyTable))
                    {
                        table.BillingMode = BillingMode.PAY_PER_REQUEST;
                        table.ProvisionedThroughput = null;
                    }
                }
            }
            .RegisterTable<MyTable>()
                .InitSchema();
2 Likes