Replies: 2 comments 1 reply
-
We cannot implement this because you cannot modify imported resources in CDK
To modify the trust policy on an imported role, CDK would need a way to modify that role, which it doesn't because the role is not defined in the application in which you are trying to modify the role. In other words, CDK would need a way to modify the CloudFormation template which has defined the role. The way to work around this would be to use a custom resource to modify the policy. If you need any direction in that, let me know, and we can convert this issue to a discussion. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the offer, I would like that. I think it would be beneficial to me as well as to others. |
Beta Was this translation helpful? Give feedback.
-
Describe the feature
Currently there is no way to add a new role to a trust relationship to an imported role.
The solution suggested in the issue #22550 cannot work as there is no 'assume_role_policy' in an imported role, regardless of immutability.
As I am using the python cdk library, there are multiple levels of abstraction as well.
Use Case
I have a mediator role inside my Stack in my main region X, which will be assumed by a regional role that exists in all my regional stacks.
I want to import the main mediator role on the other stacks (using from_role_arn), and allow specifically to the regional stack role to assume, by adding only it to the mediator role trust policy.
Proposed Solution
Either:
Or:
Add a new function of add_trusted_assuming_role in order to allow to dynamically add to trusted policy. this is also what the issue aws-iam: Make setting trust on roles more clear in overview and function descriptions #22550 expected from 'grant_assume_role'
Other Information
No response
Acknowledgements
CDK version used
python aws-cdk-lib 2.54.0
Environment details (OS name and version, etc.)
Python
Beta Was this translation helpful? Give feedback.
All reactions