How to check DynamoDB Status while chaning Throughput of WriteUnits and wait for it to complete?

How can I wait for the DynamoDB active state?

I'd like to only upscale DynamoDB while no other process is scaling/updating the table up. Thus I was wondering how I can see whether any other process is scaling up an DynamoDB table?

According to the docs of dynamodb.waitFor Function I only can check for tableExists and tableNotExists status:

var params = {
  TableName: 'STRING_VALUE' /* required */
};
dynamodb.waitFor('tableExists', params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

However this only seems to have states of 'tableExists' and 'tableNotExists' but seems not to allow to check for 'active' and 'updating' states?

Background: I'm in an multi-worker environment there every worker tries to start an upscale in case write limits are reached. How this makes necessary to wait for any scalings/updates to be completed before reading the current provisioned throughputs from the table and start a new scaling action.

One approach could be to try the UpdateTable operation and implement retry logic if you receive a ResourceInUseException (indicating some other thread is already trying to scale up the table). The retry logic would repeatedly call DescribeTable (with some backoff logic between repeated calls) and wait for the ACTIVE status (and probably make sure the new limits are not sufficient) before retrying the UpdateTable again.

You are probably aware already but just in case... :)
If your approach is to automatically scale up the table whenever you get a ProvisionedThroughputExceededException you will need to be very careful about making sure your requests are well distributed across your hash key space (or setting some hard limit on the provisioned throughput). Otherwise, in the worst case, your table could end up being automatically scaled up to support a single hot key with most of the capacity that is distributed to other keys unused.

Just got an answer from aws. My code above is working probably. On a change of througput, the table switches into the updating status. TableExists is waiting in case of the table beeing updated. It calls back as soon as the table switches back from updating to active.

dynamodb.waitFor('tableExists', params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});