-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
aws-dynamodb: addToResourcePolicy has no effect #30793
Comments
Hey @greg5123334 , thanks for sharing the detailed repro code. I can confirm that the mentioned method addToResourcePolicy() does not add the required policy.
On checking this method, it looks like the method should return the object updated with policy statements but its returning assertions. Also the inherent object being created is PolicyDocument which adds statement. Here is the PR link that introduced this change. Marking it as P3 since it has a workaround. |
I'm encountering issues with using grantRead against a dynamodb table (v1) construct where no resource policy is being added. Looking at the addToResourcePolicy for table.ts, it seems the logic is identical to the table-v2-base.ts, so I believe this affects both table constructs. |
Looks like the issue is caused by passing Tried to look around if there's an open or to-be-merged PR for this, but could not find one. |
Describe the bug
DynamoDB's TableV2 addToResourcePolicy method is not taking effect.
Expected Behavior
statements should be added to existing policy document. and in the absence of an existing policy document, one should be created on first call of
addToResourcePolicy
as documented:Current Behavior
addToResourcePolicy
has no effect on changesets.Reproduction Steps
1. Initial deploy WITHOUT policy nor statement
2. Include addToResourcePolicy WITHOUT policy
Diff
cdk diff
Deploy first addToResourcePolicy
An error occurred (PolicyNotFoundException) when calling the GetResourcePolicy operation: Resource-based policy not found for the provided ResourceArn: arn:aws:dynamodb:eu-west-1:000000000000:table/SandboxStack-TableTestV215EEA02B7-FUG73UWOHO6C
NO POLICY ADDED!!
3. Add policy via resourcePolicy prop
deploy
4. add second statement via addToResourcePolicy method
diff
cdk diff
deploy
second statement NOT included in diff nor in deployment
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.148.0 (build e5740c0)
Framework Version
No response
Node.js Version
v20.12.2
OS
Ubuntu 22.04.4 LTS
Language
TypeScript
Language Version
5.4.5
Other information
No response
The text was updated successfully, but these errors were encountered: