ZDunker
ZDunker

Reputation: 467

How to use AWS CLI to update table for a new SortKey?

I have an existing table which only has Partition key (ID) set up. During my development with dynamodb, I found out that I need to update this table to set up the Sort key also. I check the help page from aws dynamodb cli update-table, I don't see a clear way to do this. How can I use cli to accomplish this?

Upvotes: 2

Views: 376

Answers (1)

Marcin
Marcin

Reputation: 238847

Sadly, you can't add sort key to the existing table. The list of available options for updating an existing table is here and it includes:

  • Modify a table's provisioned throughput settings (for provisioned mode tables).
  • Change the table's read/write capacity mode.
  • Manipulate global secondary indexes on the table (see Using Global Secondary Indexes in DynamoDB).
  • Enable or disable DynamoDB Streams on the table (see Capturing Table Activity with DynamoDB Streams).

Thus, you have two options to rectify the issue:

  1. Create a new table with the desired sort key and migrate your data.
  2. Create a Global Secondary Indexes.

Upvotes: 4

Related Questions