Describe the bug
Previously, it's been possible to use .grant functions on dynamoDB tables and pass them a ManagedPolicy (which is allowed by the type system since ManagedPolicy implements IGrantable).
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 a ManagedPolicy 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
const table = TableV2.fromTableArn(
this,
'Table',
arnForTable,
);
table.grantReadWriteData(managedPolicy);
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
Describe the bug
Previously, it's been possible to use
.grantfunctions on dynamoDB tables and pass them aManagedPolicy(which is allowed by the type system sinceManagedPolicyimplementsIGrantable).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
.grantfunctions for dynamo tables work when passed aManagedPolicyand 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
grantfunctions. 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