import { Construct, IDependable, PolicyDocument, PolicyPrincipal, PolicyStatement } from '@aws-cdk/cdk'; import { Group } from './group'; import { Role } from './role'; import { User } from './user'; /** * A construct that represents an IAM principal, such as a user, group or role. */ export interface IPrincipal { /** * The IAM principal of this identity (i.e. AWS principal, service principal, etc). */ readonly principal: PolicyPrincipal; /** * 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: any): void; } /** * @deprecated Use IPrincipal */ export interface IIdentityResource extends IPrincipal { } export interface PolicyProps { /** * The name of the policy. If you specify multiple policies for an entity, * specify unique names. For example, if you specify a list of policies for * an IAM role, each policy must have a unique name. * * @default Uses the logical ID of the policy resource, which is ensured to * be unique within the stack. */ policyName?: string; /** * Users to attach this policy to. * You can also use `attachToUser(user)` to attach this policy to a user. */ users?: User[]; /** * Roles to attach this policy to. * You can also use `attachToRole(role)` to attach this policy to a role. */ roles?: Role[]; /** * Groups to attach this policy to. * You can also use `attachToGroup(group)` to attach this policy to a group. */ groups?: Group[]; /** * Initial set of permissions to add to this policy document. * You can also use `addPermission(statement)` to add permissions later. */ statements?: PolicyStatement[]; } /** * The AWS::IAM::Policy resource associates an IAM policy with IAM users, roles, * or groups. For more information about IAM policies, see [Overview of IAM * Policies](http://docs.aws.amazon.com/IAM/latest/UserGuide/policies_overview.html) * in the IAM User Guide guide. */ export declare class Policy extends Construct implements IDependable { /** * The policy document. */ readonly document: PolicyDocument; /** * The name of this policy. */ readonly policyName: string; /** * Lists all the elements consumers should "depend-on". */ readonly dependencyElements: IDependable[]; private readonly roles; private readonly users; private readonly groups; constructor(parent: Construct, name: string, props?: PolicyProps); /** * Adds a statement to the policy document. */ addStatement(statement: PolicyStatement): void; /** * Attaches this policy to a user. */ attachToUser(user: User): void; /** * Attaches this policy to a role. */ attachToRole(role: Role): void; /** * Attaches this policy to a group. */ attachToGroup(group: Group): void; validate(): string[]; }