I was recently tasked with updating the throughput capacities on multiple Global Secondary Index (GSI) values at my company. I figured this would take just a few minutes but I was surprised to find no options in the console for this action. The AWS CLI has a help page for this very purpose but I did not have much luck in crafting a successful request, though I use the CLI pretty regularly.

I read the AWS documentation first but found the provided examples incomplete and confusing. Official AWS blogs still showed outdated screenshots of the console. I then googled around and found many outdated blog posts telling me this simply cannot be done without a complete rebuild of my DB, or at the very least without the help of a full development SDK. I tried a handful of CLI commands and options to no avail. Before I knew it an hour had gone by.

After reading multiple posts (some of them unrelated to Dynamo) I concluded that the CLI short options are simply inadequate for complex, nested data manipulation.

Enter the –generate-cli-skeleton and –cli-input-json options. I typically find the short options faster and less cumbersome than JSON input, but for Dynamo it is a breeze and a lifesaver.

Just create a JSON file with contents like this: (can be generated using the generate flag)

{ "TableName": "thetable", "GlobalSecondaryIndexUpdates": [ { "Update": { "IndexName": "theindex", "ProvisionedThroughput": { "ReadCapacityUnits": 50, "WriteCapacityUnits": 50 } } } ] }

Then run:

$ aws dynamodb update-table --cli-input-json file://example.json

That’s it! With just the name of the table and the GSI index you updated the throughput capacity for a specific index. You can also add multiple index names to the Update section. Keep in mind that you may only update 4 indexes per database per 24 hour period (as of this writing).