-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(iam): CompositePrincipal and allow multiple principal types (#1377)
Relax constraint on IAM policy statement principals such that multiple principal types can be used in a statement. Also, the `CompositePrincipal` class can be use to construct `PolicyPrincipal`s that consist of multiple principal types (without conditions) Backfill missing addXxxPrincipal methods. Deprecate (soft) `Anyone` in favor of `AnyPrincipal`. Fixes #1201
- Loading branch information
Elad Ben-Israel
authored
Dec 18, 2018
1 parent
3d07e48
commit b942ae5
Showing
6 changed files
with
348 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/@aws-cdk/aws-iam/test/integ.composite-principal.expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"Resources": { | ||
"RoleWithCompositePrincipal17538C7F": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "ec2.amazonaws.com", | ||
"AWS": "*" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
} | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/@aws-cdk/aws-iam/test/integ.composite-principal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import cdk = require('@aws-cdk/cdk'); | ||
import iam = require('../lib'); | ||
|
||
class TestStack extends cdk.Stack { | ||
constructor(parent: cdk.App, id: string) { | ||
super(parent, id); | ||
|
||
new iam.Role(this, 'RoleWithCompositePrincipal', { | ||
assumedBy: new iam.CompositePrincipal( | ||
new iam.ServicePrincipal('ec2.amazonaws.com'), | ||
new iam.AnyPrincipal() | ||
) | ||
}); | ||
} | ||
} | ||
|
||
const app = new cdk.App(); | ||
|
||
new TestStack(app, 'iam-integ-composite-principal'); | ||
|
||
app.run(); |
Oops, something went wrong.