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

Add indexes to dynamodb.Table.fromTableAttributes #6392

Closed
skinny85 opened this issue Feb 21, 2020 · 2 comments · Fixed by #8245
Closed

Add indexes to dynamodb.Table.fromTableAttributes #6392

skinny85 opened this issue Feb 21, 2020 · 2 comments · Fixed by #8245
Assignees
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB effort/small Small work item – less than a day of effort feature-request A feature should be added or improved.

Comments

@skinny85
Copy link
Contributor

Right now, we don't allow passing indexes to dynamodb.Table.fromTableAttributes(). This means that methods like grantRead do not include the stream ARN for these Tables, even if in reality they have streams enabled.

We should add optional properties localIndexes?: string[] and globalIndexes?: string[] to TableAttributes. This should also allow us to add a bunch of methods to the ITable interface that were thus far only available on Table, like autoScalReadCapacity().

See this comment and below for more context why is this needed.

@skinny85 skinny85 added feature-request A feature should be added or improved. @aws-cdk/aws-dynamodb Related to Amazon DynamoDB effort/small Small work item – less than a day of effort labels Feb 21, 2020
@skinny85 skinny85 self-assigned this Feb 21, 2020
@balkat
Copy link

balkat commented Mar 17, 2020

The ITable grant thing is also causing us problems. We are instantiating an ITable via Table.fromTableArn(). When we do this, permission grants to lambda functions do not include the extra entry for the indexes in the Resource:

Using the Table construct we get e.g.:

            "Resource": [
                "arn:aws:dynamodb:us-east-1:REDACTED:table/VCS-UserData-vc-dev-Sea88E64FB3-TID62DP6LMCV",
                "arn:aws:dynamodb:us-east-1:REDACTED:table/VCS-UserData-vc-dev-Sea88E64FB3-TID62DP6LMCV/index/*"
            ],

When using Table.fromTableArn() we do not get the second line and any operations on the indexes are denied.

We also had to make changes elsewhere because ITable does not offer the grantFullAccess() method.

@cloud-context
Copy link

cloud-context commented May 19, 2020

This is a bit of a blocker for us also - are there any plans to get this added?

We do have a workaround which looks a bit like this:

theTable.grantReadWriteData(theFunction)
Grant.addToPrincipal({
        grantee: theFunction,
        actions: READ_WRITE_DATA_ACTIONS,
        resourceArns: [
            `${theTable.tableArn}/index/*`
        ],
        scope: theTable,
});

It works but it would be good to have indexes included for permissions out of the box

skinny85 added a commit to skinny85/aws-cdk that referenced this issue May 27, 2020
For imported Tables, the grant() methods skipped adding permissions for indexes,
as there was no way of providing the indexes on import.
This change adds globalIndexes and localIndexes properties to the TableAttributes interface,
so you can now provide indexes when calling Table.fromTableAttributes().

Fixes aws#6392
@mergify mergify bot closed this as completed in #8245 May 28, 2020
mergify bot pushed a commit that referenced this issue May 28, 2020
For imported Tables, the `grant~()` methods skipped adding permissions for indexes,
as there was no way of providing the indexes on import.
This change adds `globalIndexes` and `localIndexes` properties to the `TableAttributes` interface,
so you can now provide indexes when calling `Table.fromTableAttributes()`.

Fixes #6392

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-dynamodb Related to Amazon DynamoDB effort/small Small work item – less than a day of effort feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants