-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
does not work on CDK >=2.26 with the @aws-cdk/aws-iam:minimizePolicies feature flag enabled #153
Comments
@udondan I'm struggling to pinpoint a simple enough repro, but the single constant that leads to the error is CDK 2.26+ with the feature flag enabled. When I comment out some of the added statements to some roles, those roles don't trigger the error, so I'm guessing it only appears when the minimization kicks in. |
I'll look into it but it's not going to be soon unfortunately. Floyd also has a compression feature: .compact() Maybe you can just use this instead for now. https://iam-floyd.readthedocs.io/en/v0.382.0/vocabulary.html#compact |
@udondan I can't unfortunately - I have to use the feature flag because of aws/aws-cdk#20565 |
Since 2.29.0 this is no longer limited to a feature flag. Unfortunately there seems to be no easy solution. Before 2.26.0 the cdk just called .toJSON() to generate the JSON statement for the CFN template. IAM Floyd overwrote this method to fill the statement props it previously stored in its own propperties. Now with this policy merging, cdk accesses its props directly without calling any method. So there is nothing I can hook into. Therefore the statement props cannot be filled. IAM Floyd stores the statement elements internally to be able to do stuff like... well the exact same thing that CDK is doing now: Policy optimization. 😉 So apparently this requires a redesign of how IAM Floyd works. The fact that there are two variants, IAM Floyd and CDK IAM Floyd, doesn't make it easier. Whatever solution is implemented, it also has to work without CDK functionality. In essence: Until further notice you have to choose between IAM Floyd and CDK >= 2.29.0 (or CDK >= 2.26.0 with the feature flag) |
After thinking more about it, I actually see no way how this can work without changing the API of Floyd or removing functionality. Let me explain the situation in more detail first. Floyd has a statement minimization feature that can be called via To be able to calculate the patterns, all actions need to be stored internally without adding them to the actual statement - since there is no way to later remove or modify them, since the property holding them is private. Once an action is added, it's added. As mentioned before, in previous versions, the CDK just called As far as I recall, there is no reason other than consistency, but the same exact thing happens for conditions, resources and principals. So this could be changed, but would not solve the problem at all. Now with the policy splitting/merging feature introduced via this MR does not call So the absolutely required hook to commit the statement details is gone. With this MR this now even is always on without any feature flag. I checked all the changes and I cannot see any methods on the PolicyStatement object called at all, so there is no alternative I could hook into. And I cannot just directly call I looked into JavaScripts property getter/setter functionality, which I hadn't have a use for until today. 😊 I hoped I might be able to fake a hook when the _action property is accessed. Unfortunately a getter cannot have the same name as an actual property of the class. So this doesn't work. Where we can go from here:
|
There's a fix now thanks to @rix0rrr We can now hook into |
I'm using the package
I'm using the package in language
Describe the problem
After enabling the
@aws-cdk/aws-iam:minimizePolicies
feature flag my app doesn't synth anymore, throwing an error on synth.When adding enough statements that policy minimization kicks in, I get the following error:
cdk-iam-floyd
version:0.382
I am not sure if this is a bug in the feature itself or in cdk-iam-floyd.
The text was updated successfully, but these errors were encountered: