Skip to content

Commit

Permalink
Fix test groups and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
flochaz committed Feb 25, 2022
1 parent c76be26 commit 7f5050c
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 10 deletions.
5 changes: 1 addition & 4 deletions .projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions .projenrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ const project = new awscdk.AwsCdkConstructLibrary({
defaultReleaseBranch: 'main',
name: 'aws-dynamodb-table-multi-gsis',
repositoryUrl: 'https://github.com/flochaz/aws-dynamodb-table-multi-gsis.git',

jestOptions: {
jestConfig: {
runner: 'groups',
},
},
cdkDependenciesAsDeps: false,
cdkDependencies: ['@aws-cdk/aws-dynamodb', '@aws-cdk/custom-resources', '@aws-cdk/aws-iam'],
cdkTestDependencies: ['@aws-cdk/aws-applicationautoscaling', '@aws-cdk/aws-kinesis', '@aws-cdk/aws-kms'],
Expand All @@ -29,9 +33,7 @@ const project = new awscdk.AwsCdkConstructLibrary({
const e2e = project.addTask('test:e2e', {
exec: 'jest --group=e2e',
});
const addJestGroupSupport = 'echo $(cat package.json | jq \'.jest.runner = "groups"\') > package.json';
e2e.prependExec(addJestGroupSupport);

project.testTask.reset(`${addJestGroupSupport} && jest --group=unit`);
project.testTask.reset('jest --group=unit');

project.synth();
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
# @aws-cdk/aws-dynamodb + multi GSIs update capability


This construct is fixing https://github.com/aws/aws-cdk/issues/12246 by simply overriding [@aws-cdk/aws-dynamodb Table addGlobalSecondaryIndex](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-dynamodb/lib/table.ts#L1231) which will leverage the [@aws-cdk/custom-resource Provider](https://docs.aws.amazon.com/cdk/api/v1/docs/custom-resources-readme.html) to sequentially create Global GSIs.
This construct is fixing https://github.com/aws/aws-cdk/issues/12246 by simply overriding [@aws-cdk/aws-dynamodb Table addGlobalSecondaryIndex](https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-dynamodb/lib/table.ts#L1231) which will leverage the [@aws-cdk/custom-resource Provider](https://docs.aws.amazon.com/cdk/api/v1/docs/custom-resources-readme.html) to sequentially create Global GSIs.

## Usage

Use `@aws-cdk/aws-dynamodb` as usual except for `Table` that needs to come from `aws-dynamodb-table-multi-gsis` :


```typescript
import { AttributeType, BillingMode } from '@aws-cdk/aws-dynamodb';
import * as cdk from '@aws-cdk/core';

// Import the new version of Table
import { Table } from 'aws-dynamodb-table-multi-gsis';

const app = new cdk.App();

const stack = new cdk.Stack(app, 'integ-dynamodb-table');

const testTable = new Table(stack, 'TestTable', {
partitionKey: { name: 'id', type: AttributeType.STRING },
billingMode: BillingMode.PAY_PER_REQUEST,
});

testTable.addGlobalSecondaryIndex({
indexName: 'global1',
partitionKey: { name: 'global1', type: AttributeType.STRING },
});

testTable.addGlobalSecondaryIndex({
indexName: 'global2',
partitionKey: { name: 'global2', type: AttributeType.STRING },
});
```

## Potential caveat

If the existing table already has GSIs, it will delete and recreates the GSIs ...
143 changes: 142 additions & 1 deletion package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7f5050c

Please sign in to comment.