@Generated(value="jsii-pacmak/1.63.2 (build a8a8833)", date="2022-08-17T17:31:10.072Z") public class Policy extends Resource implements IPolicy
For more information about IAM policies, see Overview of IAM Policies in the IAM User Guide guide.
Example:
Function postAuthFn; UserPool userpool = UserPool.Builder.create(this, "myuserpool") .lambdaTriggers(UserPoolTriggers.builder() .postAuthentication(postAuthFn) .build()) .build(); // provide permissions to describe the user pool scoped to the ARN the user pool postAuthFn.role.attachInlinePolicy(Policy.Builder.create(this, "userpool-policy") .statements(List.of(PolicyStatement.Builder.create() .actions(List.of("cognito-idp:DescribeUserPool")) .resources(List.of(userpool.getUserPoolArn())) .build())) .build());
Modifier and Type | Class and Description |
---|---|
static class |
Policy.Builder
A fluent builder for
Policy . |
IPolicy.Jsii$Default, IPolicy.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
protected |
Policy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Policy(software.amazon.jsii.JsiiObjectRef objRef) |
|
Policy(software.constructs.Construct scope,
java.lang.String id) |
|
Policy(software.constructs.Construct scope,
java.lang.String id,
PolicyProps props) |
Modifier and Type | Method and Description |
---|---|
void |
addStatements(PolicyStatement... statement)
Adds a statement to the policy document.
|
void |
attachToGroup(IGroup group)
Attaches this policy to a group.
|
void |
attachToRole(IRole role)
Attaches this policy to a role.
|
void |
attachToUser(IUser user)
Attaches this policy to a user.
|
static IPolicy |
fromPolicyName(software.constructs.Construct scope,
java.lang.String id,
java.lang.String policyName)
Import a policy in this app based on its name.
|
PolicyDocument |
getDocument()
The policy document.
|
java.lang.String |
getPolicyName()
The name of this policy.
|
protected java.util.List<java.lang.String> |
validate()
Validate the current construct.
|
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResource
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyRemovalPolicy, getEnv, getStack
getNode
protected Policy(software.amazon.jsii.JsiiObjectRef objRef)
protected Policy(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public Policy(software.constructs.Construct scope, java.lang.String id, PolicyProps props)
scope
- This parameter is required.id
- This parameter is required.props
- public Policy(software.constructs.Construct scope, java.lang.String id)
scope
- This parameter is required.id
- This parameter is required.public static IPolicy fromPolicyName(software.constructs.Construct scope, java.lang.String id, java.lang.String policyName)
scope
- This parameter is required.id
- This parameter is required.policyName
- This parameter is required.public void addStatements(PolicyStatement... statement)
statement
- This parameter is required.public void attachToGroup(IGroup group)
group
- This parameter is required.public void attachToRole(IRole role)
role
- This parameter is required.public void attachToUser(IUser user)
user
- This parameter is required.protected java.util.List<java.lang.String> validate()
This method can be implemented by derived constructs in order to perform validation logic. It is called on all constructs before synthesis.
public PolicyDocument getDocument()
public java.lang.String getPolicyName()
getPolicyName
in interface IPolicy