Class PrincipalWithConditions

All Implemented Interfaces:
IAssumeRolePrincipal, IComparablePrincipal, IGrantable, IPrincipal,

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:29:57.365Z") @Stability(Stable) public class PrincipalWithConditions extends PrincipalBase
An IAM principal with additional conditions specifying when the policy is in effect.

For more information about conditions, see:


 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 Object conditions;
 IPrincipal principal;
 PrincipalWithConditions principalWithConditions = new PrincipalWithConditions(principal, Map.of(
         "conditionsKey", conditions));
  • Constructor Details

    • PrincipalWithConditions

      protected PrincipalWithConditions( objRef)
    • PrincipalWithConditions

      protected PrincipalWithConditions( initializationMode)
    • PrincipalWithConditions

      @Stability(Stable) public PrincipalWithConditions(@NotNull IPrincipal principal, @NotNull Map<String,Object> conditions)
      principal - This parameter is required.
      conditions - This parameter is required.
  • Method Details

    • addCondition

      @Stability(Stable) public void addCondition(@NotNull String key, @NotNull Object value)
      Add a condition to the principal.

      key - This parameter is required.
      value - This parameter is required.
    • addConditions

      @Stability(Stable) public void addConditions(@NotNull Map<String,Object> conditions)
      Adds multiple conditions to the principal.

      Values from the conditions parameter will overwrite existing values with the same operator and key.

      conditions - This parameter is required.
    • addToPolicy

      @Stability(Stable) @NotNull public Boolean addToPolicy(@NotNull PolicyStatement statement)
      Add to the policy of this principal.

      Specified by:
      addToPolicy in interface IPrincipal
      addToPolicy in class PrincipalBase
      statement - This parameter is required.
      true if the statement was added, false if the principal in question does not have a policy document to add the statement to.
    • addToPrincipalPolicy

      @Stability(Stable) @NotNull public AddToPrincipalPolicyResult addToPrincipalPolicy(@NotNull PolicyStatement statement)
      Add to the policy of this principal.

      Specified by:
      addToPrincipalPolicy in interface IPrincipal
      addToPrincipalPolicy in class PrincipalBase
      statement - This parameter is required.
    • appendDedupe

      @Stability(Stable) @Nullable protected String appendDedupe(@NotNull String append)
      Append the given string to the wrapped principal's dedupe string (if available).

      append - This parameter is required.
    • dedupeString

      @Stability(Stable) @Nullable public String dedupeString()
      Return whether or not this principal is equal to the given principal.
      Specified by:
      dedupeString in interface IComparablePrincipal
      Specified by:
      dedupeString in class PrincipalBase
    • toJSON

      @Stability(Stable) @NotNull public Map<String,List<String>> toJSON()
      JSON-ify the principal.

      Used when JSON.stringify() is called

      toJSON in class PrincipalBase
    • toString

      @Stability(Stable) @NotNull public String toString()
      Returns a string representation of an object.
      toString in class PrincipalBase
    • getAssumeRoleAction

      @Stability(Stable) @NotNull public String getAssumeRoleAction()
      When this Principal is used in an AssumeRole policy, the action to use.
      Specified by:
      getAssumeRoleAction in interface IPrincipal
      getAssumeRoleAction in class PrincipalBase
    • getConditions

      @Stability(Stable) @NotNull public Map<String,Object> getConditions()
      The conditions under which the policy is in effect.

      See the IAM documentation.

    • getPolicyFragment

      @Stability(Stable) @NotNull public PrincipalPolicyFragment getPolicyFragment()
      Return the policy fragment that identifies this principal in a Policy.
      Specified by:
      getPolicyFragment in interface IPrincipal
      Specified by:
      getPolicyFragment in class PrincipalBase
    • getPrincipalAccount

      @Stability(Stable) @Nullable public String getPrincipalAccount()
      The AWS account ID of this principal.

      Can be undefined when the account is not known (for example, for service principals). Can be a Token - in that case, it's assumed to be AWS::AccountId.

      Specified by:
      getPrincipalAccount in interface IPrincipal
      getPrincipalAccount in class PrincipalBase