This branch bumps version compatibility of the construct to CDK 2.x while removing most dependency to projen. If you still choose to use it in your project as is, please publish to a (private) registry of your choosing as per the instructions under the Development section.
This construct is fixing aws/aws-cdk#12246 by simply overriding @aws-cdk/aws-dynamodb Table addGlobalSecondaryIndex which will leverage the @aws-cdk/custom-resource Provider to sequentially create Global GSIs.
Use aws-cdk-lib/aws-dynamodb as usual except for Table that needs to come from aws-dynamodb-table-multi-gsis :
import { AttributeType, BillingMode } from 'aws-cdk-lib/aws-dynamodb';
import * as cdk from 'aws-cdk-lib/core';
// Import the new version of Table
import { Table as MultiGsisTable } from '<your-registry>/aws-dynamodb-table-multi-gsis';
const app = new cdk.App();
const stack = new cdk.Stack(app, 'integ-dynamodb-table');
const testTable = new MultiGsisTable(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 },
});If the existing table already has
- 1 GSI, it will delete it and recreate it with new way of managing GSIs ...
- 2 or more GSIs, update will fail because it will try to delete those GSIs and recreate them with the new method but since it's not possible to delete more than one using the old management system the stack update will fail :( => workaround delete those GSIs from your cdk app before changing to new implementation
To test the construct, you can run the following commands:
npm install
npm run build
npm run bundle:dynamoDBUpdateTable.lambda
npm run testTo release a new version of the construct, you can run the following commands:
npm install
npm run build
npm run bundle:dynamoDBUpdateTable.lambda
npm publish