fix(iam): ManagedPolicy can again be granted actions on resources #33115
+33,115
−136
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #32795.
Reason for this change
Before this change, ManagedPolicy explicitly throw and error for statements like following for TableV2. This was supported in v2.131.
Description of changes
What code changes did you make?
policyFragment
now returns and empty PrincipalPolicyFragment. This enables the user to attach actions to policies. The generated CFN template will now contain the required actions, effects and resources blocks. It will still require the app to attach this policy to a Principal, user or role for it to work.
Have you made any important design decisions?
See above.
What AWS use cases does this change enable? To enable the use cases, which AWS service features are utilized?
Restores parity with a feature until 2.131 which allowed CDK apps to grant actions on resources to generate Policy Fragments for managed resources.
Describe any new or updated permissions being added
None
Description of how you validated changes
Yes to Both.
Integration test has been majorly refactored to do deployment checks as well in addition to the CFN checks.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license