Skip to content

Support GSI and LSI through DynamoDB Table #655

@jungseoklee

Description

@jungseoklee

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
            }
        }
    ]
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions