How to prevent generating default policies during IAM role creation in AWS CDK #19974
-
Hi there! I'm developing the App in AWS CDK which will create ESC scheduled task, event bridge rule and some IAM roles with inline policies. This resources are created in same stack. For better controlling I decided to describe clearly IAM roles and appropriate inline policies (pseudo code is down below).
This functions are used in another functions which create Task Definition and Event Bridge Target
When I perform
Is there any way to prevent creation this autogenerated (DefaultPolicyA513DFBF) policies? Also may be someone found a way how to provide names for this policies. Appreciate for any advices. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
You could use Aspects to walk and modify the tree, but without seeing what the CDK is producing, it's hard to know what the policy is doing. A lot of CDK constructs create a role and policy out of the gate simply to make sure that there are appropriate roles in place for that construct. |
Beta Was this translation helpful? Give feedback.
-
Hello! Reopening this discussion to make it searchable. |
Beta Was this translation helpful? Give feedback.
If you don't want CDK to add policy statements to a Role passed into any construct, you can pass in
Role.withoutPolicyUpdates()
when needed.