Skip to content

Commit

Permalink
fix(dynamodb): the maximum number of nonKeyAttributes is 100, not 20 (a…
Browse files Browse the repository at this point in the history
…ws#8186)

The validation for `nonKeyAttributes` count on the secondaryt indexes
was incorrectly checked at `20`, while the real limit is `100` (it has
been raised since the code was initially authored).

Fixes aws#8095

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
RomainMuller authored May 25, 2020
1 parent 575f1db commit 0393528
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,9 +1114,9 @@ export class Table extends TableBase {
* @param nonKeyAttributes a list of non-key attribute names
*/
private validateNonKeyAttributes(nonKeyAttributes: string[]) {
if (this.nonKeyAttributes.size + nonKeyAttributes.length > 20) {
if (this.nonKeyAttributes.size + nonKeyAttributes.length > 100) {
// https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html#limits-secondary-indexes
throw new RangeError('a maximum number of nonKeyAttributes across all of secondary indexes is 20');
throw new RangeError('a maximum number of nonKeyAttributes across all of secondary indexes is 100');
}

// store all non-key attributes
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ test('error when adding a global secondary index with projection type INCLUDE, b
const table = new Table(stack, CONSTRUCT_NAME, { partitionKey: TABLE_PARTITION_KEY, sortKey: TABLE_SORT_KEY });
const gsiNonKeyAttributeGenerator = NON_KEY_ATTRIBUTE_GENERATOR(GSI_NON_KEY);
const gsiNonKeyAttributes: string[] = [];
for (let i = 0; i < 21; i++) {
for (let i = 0; i < 101; i++) {
gsiNonKeyAttributes.push(gsiNonKeyAttributeGenerator.next().value);
}

Expand All @@ -1124,7 +1124,7 @@ test('error when adding a global secondary index with projection type INCLUDE, b
sortKey: GSI_SORT_KEY,
projectionType: ProjectionType.INCLUDE,
nonKeyAttributes: gsiNonKeyAttributes,
})).toThrow(/a maximum number of nonKeyAttributes across all of secondary indexes is 20/);
})).toThrow(/a maximum number of nonKeyAttributes across all of secondary indexes is 100/);
});

test('error when adding a global secondary index with read or write capacity on a PAY_PER_REQUEST table', () => {
Expand Down

0 comments on commit 0393528

Please sign in to comment.