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 Details

    • Builder

      public Builder()
  • Method Details

    • document

      @Stability(Stable) public PolicyProps.Builder document(PolicyDocument document)
      Sets the value of PolicyProps.getDocument()
      Parameters:
      document - Initial PolicyDocument to use for this Policy. If omited, any PolicyStatement provided in the statements property will be applied against the empty default PolicyDocument.
      Returns:
      this
    • force

      @Stability(Stable) public PolicyProps.Builder force(Boolean force)
      Sets the value of PolicyProps.getForce()
      Parameters:
      force - Force creation of an AWS::IAM::Policy. Unless set to true, this Policy construct will not materialize to an AWS::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

      @Stability(Stable) public PolicyProps.Builder groups(List<? extends IGroup> groups)
      Sets the value of PolicyProps.getGroups()
      Parameters:
      groups - Groups to attach this policy to. You can also use attachToGroup(group) to attach this policy to a group.
      Returns:
      this
    • policyName

      @Stability(Stable) public PolicyProps.Builder policyName(String policyName)
      Sets the value of PolicyProps.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

      @Stability(Stable) public PolicyProps.Builder roles(List<? extends IRole> roles)
      Sets the value of PolicyProps.getRoles()
      Parameters:
      roles - Roles to attach this policy to. You can also use attachToRole(role) to attach this policy to a role.
      Returns:
      this
    • statements

      @Stability(Stable) public PolicyProps.Builder statements(List<? extends PolicyStatement> statements)
      Sets the value of PolicyProps.getStatements()
      Parameters:
      statements - Initial set of permissions to add to this policy document. You can also use addStatements(...statement) to add permissions later.
      Returns:
      this
    • users

      @Stability(Stable) public PolicyProps.Builder users(List<? extends IUser> users)
      Sets the value of PolicyProps.getUsers()
      Parameters:
      users - Users to attach this policy to. You can also use attachToUser(user) to attach this policy to a user.
      Returns:
      this
    • build

      @Stability(Stable) public PolicyProps build()
      Builds the configured instance.
      Specified by:
      build in interface software.amazon.jsii.Builder<PolicyProps>
      Returns:
      a new instance of PolicyProps
      Throws:
      NullPointerException - if any required attribute was not provided