Class PolicyProps.Builder
java.lang.Object
software.amazon.awscdk.services.iam.PolicyProps.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<PolicyProps>
- Enclosing interface:
- PolicyProps
@Stability(Stable)
public static final class PolicyProps.Builder
extends Object
implements software.amazon.jsii.Builder<PolicyProps>
A builder for
PolicyProps
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the configured instance.document
(PolicyDocument document) Sets the value ofPolicyProps.getDocument()
Sets the value ofPolicyProps.getForce()
Sets the value ofPolicyProps.getGroups()
policyName
(String policyName) Sets the value ofPolicyProps.getPolicyName()
Sets the value ofPolicyProps.getRoles()
statements
(List<? extends PolicyStatement> statements) Sets the value ofPolicyProps.getStatements()
Sets the value ofPolicyProps.getUsers()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
document
Sets the value ofPolicyProps.getDocument()
- Parameters:
document
- Initial PolicyDocument to use for this Policy. If omited, anyPolicyStatement
provided in thestatements
property will be applied against the empty defaultPolicyDocument
.- Returns:
this
-
force
Sets the value ofPolicyProps.getForce()
- Parameters:
force
- Force creation of anAWS::IAM::Policy
. Unless set totrue
, thisPolicy
construct will not materialize to anAWS::IAM::Policy
CloudFormation resource in case it would have no effect (for example, if it remains unattached to an IAM identity or if it has no statements). This is generally desired behavior, since it prevents creating invalid--and hence undeployable--CloudFormation templates.In cases where you know the policy must be created and it is actually an error if no statements have been added to it, you can set this to
true
.- Returns:
this
-
groups
Sets the value ofPolicyProps.getGroups()
- Parameters:
groups
- Groups to attach this policy to. You can also useattachToGroup(group)
to attach this policy to a group.- Returns:
this
-
policyName
Sets the value ofPolicyProps.getPolicyName()
- Parameters:
policyName
- 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.- Returns:
this
-
roles
Sets the value ofPolicyProps.getRoles()
- Parameters:
roles
- Roles to attach this policy to. You can also useattachToRole(role)
to attach this policy to a role.- Returns:
this
-
statements
@Stability(Stable) public PolicyProps.Builder statements(List<? extends PolicyStatement> statements) Sets the value ofPolicyProps.getStatements()
- Parameters:
statements
- Initial set of permissions to add to this policy document. You can also useaddStatements(...statement)
to add permissions later.- Returns:
this
-
users
Sets the value ofPolicyProps.getUsers()
- Parameters:
users
- Users to attach this policy to. You can also useattachToUser(user)
to attach this policy to a user.- Returns:
this
-
build
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<PolicyProps>
- Returns:
- a new instance of
PolicyProps
- Throws:
NullPointerException
- if any required attribute was not provided
-