Skip to content

Commit

Permalink
fix(iam): allow CompositePrincipal construction with spread (#2507)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchlloyd authored and rix0rrr committed May 10, 2019
1 parent 1feda0c commit eb13741
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 eb13741

Please sign in to comment.