-
Notifications
You must be signed in to change notification settings - Fork 4k
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
(dynamodb): grantReadData() should always grant permissions to secondary indexes #13703
Comments
Hey @ahammond , thanks for opening the issue. That's the behavior today. See this test: aws-cdk/packages/@aws-cdk/aws-dynamodb/test/dynamodb.test.ts Lines 2221 to 2277 in aa45ede
Did you provide your indexes? How is Thanks, |
@skinny85 The table is created in the app's persistent stack:
And referenced by the lambda in our API-GW stack:
I'll see if we can grant you read on the relevant repos. |
This is the problem: this.emailAuthorizationTable = Table.fromTableArn(
this,
emailAuthName.addSuffix(iface).pascal,
emailAuthorization.tableArn,
); This "forgets" the indexes (you didn't specify the Table has any when importing it). Why are you doing it that way? Why are you not just passing the |
We had what looked like a circular dependency when just passing the object directly. This was a first and not terribly great iteration in what has become a pretty active desire to decouple our stacks. I'll take a look at adding the index on import. |
It seems to me that there's a reasonable argument that |
I'm not completely opposed to this idea @ahammond . I'm turning this into a feature request. PRs are welcome, as always 😉. |
Might require research confirming that granting those permissions on a Table without any indexes defined works without any problems. |
Note that if you import dynamodb using example:
Note my reason for separating databases and APIs/non-storage deployments is lifetime: It's okay to blow destroyt stateless stuff like APIs in case of re-entrancy bugs in CDK or CloudFormation, but really bad to have to destroy databases and recreate them. From what I can tell, sharing objects does not let you have independent lifetimes for databases and APIs, but export/import does. |
@pszabop thanks for sharing! |
+1 for a way to grant access to indexes without knowing what they are up-front. I'd rather not have to keep track of all the index names across stacks, especially when using |
Seems like the last PR got closed due to staleness. Other than commit message convention and failing test issues, did you all have any issues with the previous PR? I'd love to see this feature. The whole index permissioning issue has been the most frustrating part of migrating from SAM to CDK. @ahammond Do you have capacity to continue on this, or are you cool with me picking it up? |
@bilalq I've been swamped for months. Please go ahead. |
@bilalq Any luck you got time to commit a fix here soon? |
Is there still a fix en route for this? |
…20682) When we use imported tables, grant methods don't grant permissions for indexes unless local indexes or global secondary indexes are specified. The information for indexes is used only for grant permissions now. Users either keep track of index information of the imported tables or specify random index (e.g. `*`) as a workaround to obtain the permissions. This PR let imported tables grant permissions for indexes without providing indexes. close #13703 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…ws#20682) When we use imported tables, grant methods don't grant permissions for indexes unless local indexes or global secondary indexes are specified. The information for indexes is used only for grant permissions now. Users either keep track of index information of the imported tables or specify random index (e.g. `*`) as a workaround to obtain the permissions. This PR let imported tables grant permissions for indexes without providing indexes. close aws#13703 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Reproduction Steps
Then we query on a secondary index on myTable and get
What did you expect to happen?
Expected the lambda to be able to query the table, including on secondary indices.
What actually happened?
Environment
Other
Resolved / workaround by adding
The fix probably belongs somewhere near
aws-cdk/packages/@aws-cdk/aws-dynamodb/lib/table.ts
Line 906 in 0ea4b19
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: