-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(iam): no trust policy added for cross-account roles #5812
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,26 @@ | ||||||
import { Token } from '@aws-cdk/core'; | ||||||
|
||||||
/** | ||||||
* Return whether the given accounts are definitely different. | ||||||
* | ||||||
* If one or both of them are agnostic, return false (we don't know). | ||||||
*/ | ||||||
export function accountsAreDefinitelyDifferent(account1: string | undefined, | ||||||
account2: string | undefined): boolean { | ||||||
return !Token.isUnresolved(account1) && !Token.isUnresolved(account2) && account1 !== account2; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Return whether two accounts are the same account | ||||||
* | ||||||
* Returns undefined if one is agnostic and the other one isn't. | ||||||
*/ | ||||||
export function sameAccount(account1: string | undefined, account2: string | undefined): boolean | undefined { | ||||||
// Both agnostic in 99% of cases means they will be deployed to the same environment, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmmmmokay... |
||||||
// so treat as the same. | ||||||
if (Token.isUnresolved(account1) && Token.isUnresolved(account2)) { return true; } | ||||||
|
||||||
// One agnostic and the other one not means "shug". | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (Token.isUnresolved(account1) || Token.isUnresolved(account2)) { return undefined; } | ||||||
return account1 === account2; | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,8 @@ export class UnknownPrincipal implements IPrincipal { | |
this.resource.node.addWarning(`Add statement to this resource's role: ${repr}`); | ||
return true; // Pretend we did the work. The human will do it for us, eventually. | ||
} | ||
|
||
public sameAccount(_scope: IConstruct): boolean | undefined { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe return an enum instead of using |
||
return undefined; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cdk.Stack
and not acdk.IConstruct
. It will make this API much clearer._internal
? It's used only inside this module and TBH it feels like it's polluting the interface.