Skip to content

Commit

Permalink
Allow CompositePrincipal construction with spread
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchlloyd committed May 9, 2019
1 parent 0acfa8b commit c6c288b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/@aws-cdk/aws-iam/lib/policy-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,13 @@ export class CompositePrincipal extends PrincipalBase {
public readonly assumeRoleAction: string;
private readonly principals = new Array<PrincipalBase>();

constructor(principal: PrincipalBase, ...additionalPrincipals: PrincipalBase[]) {
constructor(...principals: PrincipalBase[]) {
super();
this.assumeRoleAction = principal.assumeRoleAction;
this.addPrincipals(principal);
this.addPrincipals(...additionalPrincipals);
if (principals.length === 0) {
throw new Error('CompositePrincipals must be constructed with at least 1 Principal but none were passed.');
}
this.assumeRoleAction = principals[0].assumeRoleAction;
this.addPrincipals(...principals);
}

public addPrincipals(...principals: PrincipalBase[]): this {
Expand Down

0 comments on commit c6c288b

Please sign in to comment.