amazon-web-servicesamazon-dynamodbamazon-dynamodb-local

How do I create several GSIs in DynamoDB Local?


I have been using DynamoDB Local (currently 1.21.0) for testing my Java application using the v2 Enhanced Client for a long time, and I have used both GSIs and LSIs successfully. However, I am now trying to create a new table with 12 GSIs and no LSIs, which is within the default AWS quota of 20 per table. Attempting the CreateTable operation results in the error

No more than 20 attributes per table can be projected into Local Secondary Indices (Service: DynamoDb, Status Code: 400, Request ID: b08b6891-ffe6-4576-a080-fddb55c9880a)

I am projecting 10 or fewer attributes into each of these GSIs, and the table object has 19 attributes including derived index attributes.

Why is DynamoDB Local returning an error about "too many attributes in LSIs" when I'm not storing that many attributes in the first place and I'm not using LSIs at all? How can I get this table working?


Solution

  • If you're getting an exception then I suggest that you just use ALL projection type for your testing.

    DynamoDB has a limit of 100 attributes projected per table, 12 * 20 = 240 which exceeds the projection limit.

    https://aws.amazon.com/about-aws/whats-new/2018/12/amazon-dynamodb-increases-the-number-of-global-secondary-indexes-and-projected-index-attributes-you-can-create-per-table/

    As for the vague/wrong exception, I'll bring that to the attention of the team.