Class Policy
The AWS::IAM::Policy resource associates an inline IAM policy with IAM users, roles, or groups. For more information about IAM policies, see Overview of IAM Policies in the IAM User Guide guide.
Inherited Members
Namespace: Amazon.CDK.AWS.IAM
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Policy : Resource, IPolicy, IResource, IGrantable
Syntax (vb)
Public Class Policy
Inherits Resource
Implements IPolicy, IResource, IGrantable
Remarks
ExampleMetadata: infused
Examples
Function postAuthFn;
var userpool = new UserPool(this, "myuserpool", new UserPoolProps {
LambdaTriggers = new UserPoolTriggers {
PostAuthentication = postAuthFn
}
});
// provide permissions to describe the user pool scoped to the ARN the user pool
postAuthFn.Role.AttachInlinePolicy(new Policy(this, "userpool-policy", new PolicyProps {
Statements = new [] { new PolicyStatement(new PolicyStatementProps {
Actions = new [] { "cognito-idp:DescribeUserPool" },
Resources = new [] { userpool.UserPoolArn }
}) }
}));
Synopsis
Constructors
Policy(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Policy(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Policy(Construct, String, IPolicyProps) |
Properties
Document | The policy document. |
GrantPrincipal | The principal to grant permissions to. |
PolicyName | The name of this policy. |
Methods
AddStatements(PolicyStatement[]) | Adds a statement to the policy document. |
AttachToGroup(IGroup) | Attaches this policy to a group. |
AttachToRole(IRole) | Attaches this policy to a role. |
AttachToUser(IUser) | Attaches this policy to a user. |
FromPolicyName(Construct, String, String) | Import a policy in this app based on its name. |
Constructors
Policy(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Policy(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Policy(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Policy(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Policy(Construct, String, IPolicyProps)
public Policy(Construct scope, string id, IPolicyProps props = null)
Parameters
- scope Constructs.Construct
- id System.String
- props IPolicyProps
Properties
Document
GrantPrincipal
The principal to grant permissions to.
public virtual IPrincipal GrantPrincipal { get; }
Property Value
PolicyName
The name of this policy.
public virtual string PolicyName { get; }
Property Value
System.String
Remarks
Attribute: true
Methods
AddStatements(PolicyStatement[])
Adds a statement to the policy document.
public virtual void AddStatements(params PolicyStatement[] statement)
Parameters
- statement PolicyStatement[]
AttachToGroup(IGroup)
Attaches this policy to a group.
public virtual void AttachToGroup(IGroup group)
Parameters
- group IGroup
AttachToRole(IRole)
AttachToUser(IUser)
FromPolicyName(Construct, String, String)
Import a policy in this app based on its name.
public static IPolicy FromPolicyName(Construct scope, string id, string policyName)
Parameters
- scope Constructs.Construct
- id System.String
- policyName System.String
Returns