Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GSI and LSI through DynamoDB Table #655

Closed
jungseoklee opened this issue Sep 2, 2018 · 5 comments
Closed

Support GSI and LSI through DynamoDB Table #655

jungseoklee opened this issue Sep 2, 2018 · 5 comments

Comments

@jungseoklee
Copy link
Contributor

Hi AWS CDK,

First of all, I am happy to see this project :)

As DynamoDB user, it would be great to support GSI and LSI through DynamoDB Table. Currently, a low-level approach is required as follows if GSI or LSI is needed, which makes high-level methods, such as addPartitionKey and addSortKey, less useful.

new dynamodb.cloudformation.TableResource(this, 'cdk', {
    attributeDefinitions: [
        {
            attributeName: 'foo',
            attributeType: 'S'
        },
        {
            attributeName: 'bar',
            attributeType: 'S'
        }
    ],
    tableName: 'cdk',
    keySchema: [
        {
            attributeName: 'foo',
            keyType: 'HASH'
        },
        {
            attributeName: 'bar',
            keyType: 'RANGE'
        }
    ],
    provisionedThroughput: {
        readCapacityUnits: 10,
        writeCapacityUnits: 10
    },
    globalSecondaryIndexes: [
        {
            indexName: 'cdk-gsi',
            keySchema: [
                {
                    attributeName: 'bar',
                    keyType: 'HASH'
                }
            ],
            projection: {
                projectionType: 'ALL'
            },
            provisionedThroughput: {
                readCapacityUnits: 10,
                writeCapacityUnits: 10
            }
        }
    ]
});
@eladb
Copy link
Contributor

eladb commented Sep 3, 2018

Definitely a missing feature in our dynamo db library

@eladb
Copy link
Contributor

eladb commented Sep 3, 2018

#606

@jungseoklee
Copy link
Contributor Author

I am curious about how you implement this feature: are you considering sort of public methods, such as addGlobalSecondaryIndex, or a totally different approach?

@eladb
Copy link
Contributor

eladb commented Sep 4, 2018

Yes, something like that should work. If it makes sense, we sometimes also like to provide a declarative syntax via props, but only if it's not too cumbersome.

@jungseoklee
Copy link
Contributor Author

I close this issue because both GSI and LSI are supported now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants