-
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): grant calls no longer working when passed a ManagedPolicy #32795
Comments
Can you show me how do you define if you use fromXxx() method, you get |
@pahud it's defined within the same CDK stack I'm using the
There are a number of other calls in the stack to add other statements to the policy (many of which are constructed manually via |
Yes I am seeing
The error is thrown from
Reason:
which was fixed in this PR. so it should be a bug fix not a breaking change. |
I don't think that PR is the root cause of this bug? If I'm reading it correctly that PR adds |
Describe the bug
Previously, it's been possible to use
.grant
functions on dynamoDB tables and pass them aManagedPolicy
(which is allowed by the type system sinceManagedPolicy
implementsIGrantable
).Under 2.174.0, that results in an error:
Cannot use a ManagedPolicy as the 'Principal' or 'NotPrincipal' in an IAM Policy
.This is a change in behaviour, and it's also inconsistent with e.g. S3 where it's still possible to call
bucket.grantReadWrite(managedPolicy);
Regression Issue
Last Known Working CDK Version
2.131.0
Expected Behavior
.grant
functions for dynamo tables work when passed aManagedPolicy
and add the appropriate policy statements.Current Behavior
Error thrown: Cannot use a ManagedPolicy as the 'Principal' or 'NotPrincipal' in an IAM Policy
Reproduction Steps
Error is visible in CDK unit tests which verify the managed policy composition.
Possible Solution
No response
Additional Information/Context
I'm not sure if the new behaviour is correct in that a ManagedPolicy is not in fact a Principal, and hence the previous behaviour shouldn't have been allowed, but it should be consistent and obvious from documentation where you can and can't use the convenience
grant
functions. At present they work in this scenario for other library areas e.g. S3.CDK CLI Version
2.174.0
Framework Version
No response
Node.js Version
18
OS
Mac OS
Language
TypeScript
Language Version
5.x
Other information
No response
The text was updated successfully, but these errors were encountered: