fix(iam): only create policies for imported roles if they're in the same account as the owning stack#3716
Conversation
Pull Request Checklist
|
|
I'm actually wondering whether the logic around stacks without When providing the So: const stack = new Stack(app, 'S');
// this role will create new policies
iam.Role.fromRoleArn(stack, 'R1',
`arn:aws:iam::${Aws.ACCOUNT_ID}:role/MyRole`);
// this role will ignore all calls to `addToRolePolicy` and `attachInlinePolicy`
iam.Role.fromRoleArn(stack, 'R2',
'arn:aws:iam::123456789012:role/MyRole');Thoughts on this @rix0rrr ? |
|
@rix0rrr can you address my question from above? |
Pull Request Checklist
|
I don't think the 2 are exclusive. I want to do #3753 as well. This is more about changing the current behavior, which is obviously incorrect for the case where the ARN account and the Stack account are different. |
|
Hanging out to see this issue fixed. Code pipeline basically useless in cross-account environments :( |
d551d6e to
f9d731d
Compare
|
After talking with @rix0rrr offline, submitted a new revision. I've covered a lot more cases, included inline policies added with I would recommend starting the review with looking at the unit tests, as they document what is the behavior we expect for the various cases (and there is a lot of different cases here!). |
|
This PR closes #2985, by the way. |
f9d731d to
ee71990
Compare
|
I've re-worked the tests completely; @rix0rrr let me know how you like their structure now. |
|
Love it! Still a shit-ton to read, but this structure is great! |
|
Still prefer that we change the |
ee71990 to
65c988f
Compare
|
Submitted a new revision. @rix0rrr can you go through the tests, and confirm all of them have (in your mind) the correct behavior right now? I feel like a few could go either way, so I just wanted to confirm the expectations for the behavior are the same. |
|
Actually, if you could confirm that as well @michaeljfazio , that would be super helpful :) |
rix0rrr
left a comment
There was a problem hiding this comment.
@rix0rrr can you go through the tests, and confirm all of them have (in your mind) the correct behavior right now?
I believe they do (or at least, the most important ones I looked at). Do you have any particular ones in mind you're concerned about?
65c988f to
792ff10
Compare
|
Included last comments and rebased. |
|
Thank you for contributing! Your pull request is now being automatically merged. |
|
Thank you for contributing! Your pull request is now being automatically merged. |
We also allow adding policies to the imported role if the owning stack does not have an account specified.
Fixes #2985
Fixes #3025
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license