-
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.
Introduce Role -> IIdentity -> IPrincipal
- Loading branch information
Rico Huijbers
committed
Jan 27, 2019
1 parent
876b26d
commit 19ad316
Showing
11 changed files
with
291 additions
and
255 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
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,37 @@ | ||
import cdk = require('@aws-cdk/cdk'); | ||
import { Policy } from "./policy"; | ||
import { PolicyStatement } from "./policy-document"; | ||
import { IPrincipal, PrincipalPolicyFragment } from "./principals"; | ||
|
||
/** | ||
* A construct that represents an IAM principal, such as a user, group or role. | ||
*/ | ||
export interface IIdentity extends IPrincipal { | ||
/** | ||
* Adds an IAM statement to the default inline policy associated with this | ||
* principal. If a policy doesn't exist, it is created. | ||
*/ | ||
addToPolicy(statement: PolicyStatement): void; | ||
|
||
/** | ||
* Attaches an inline policy to this principal. | ||
* This is the same as calling `policy.addToXxx(principal)`. | ||
* @param policy The policy resource to attach to this principal. | ||
*/ | ||
attachInlinePolicy(policy: Policy): void; | ||
|
||
/** | ||
* Attaches a managed policy to this principal. | ||
* @param arn The ARN of the managed policy | ||
*/ | ||
attachManagedPolicy(arn: string): void; | ||
} | ||
|
||
export abstract class IdentityBase extends cdk.Construct implements IIdentity { | ||
public readonly assumeRoleAction: string = 'sts:AssumeRole'; | ||
|
||
public abstract policyFragment: PrincipalPolicyFragment; | ||
public abstract addToPolicy(statement: PolicyStatement): void; | ||
public abstract attachInlinePolicy(policy: Policy): void; | ||
public abstract attachManagedPolicy(arn: string): void; | ||
} |
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
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
Oops, something went wrong.