When I deploy a CDK stack - it creates several roles, both explicitly e.g. via iam.Role construct, and implicitly e.g. when roles are created internally by Level 2 constructs.
Is there a way to attach an existing permission boundary to all the roles being created by the stack - both explicit and implicit?
Yes, through aspects.
You can add the following in
bin/app.ts(the file might be named differently):Please note that we're adding a managed policy
GlobalPermissionBoundaryPolicythat defines the permission boundary once. Also, the aspect handles bothnew iam.Role()as well as anynew CfnRole()defined by your or library code.