Class PrincipalWithConditions

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.iam.PrincipalBase
software.amazon.awscdk.services.iam.PrincipalWithConditions
All Implemented Interfaces:
IAssumeRolePrincipal, IComparablePrincipal, IGrantable, IPrincipal, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-04T00:39:33.342Z") @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: https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html

Example:

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

    • PrincipalWithConditions

      protected PrincipalWithConditions(software.amazon.jsii.JsiiObjectRef objRef)
    • PrincipalWithConditions

      protected PrincipalWithConditions(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • PrincipalWithConditions

      @Stability(Stable) public PrincipalWithConditions(@NotNull IPrincipal principal, @NotNull Map<String,Object> conditions)
      Parameters:
      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.

      Parameters:
      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.

      Parameters:
      conditions - This parameter is required.
    • addToAssumeRolePolicy

      @Stability(Stable) public void addToAssumeRolePolicy(@NotNull PolicyDocument doc)
      Add the principal to the AssumeRolePolicyDocument.

      Add the statements to the AssumeRolePolicyDocument necessary to give this principal permissions to assume the given role.

      Specified by:
      addToAssumeRolePolicy in interface IAssumeRolePrincipal
      Overrides:
      addToAssumeRolePolicy in class PrincipalBase
      Parameters:
      doc - This parameter is required.
    • addToPolicy

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

      Overrides:
      addToPolicy in class PrincipalBase
      Parameters:
      statement - This parameter is required.
    • addToPrincipalPolicy

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

      Specified by:
      addToPrincipalPolicy in interface IPrincipal
      Overrides:
      addToPrincipalPolicy in class PrincipalBase
      Parameters:
      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).

      Parameters:
      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

      Overrides:
      toJSON in class PrincipalBase
    • toString

      @Stability(Stable) @NotNull public String toString()
      Returns a string representation of an object.
      Overrides:
      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
      Overrides:
      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
      Overrides:
      getPrincipalAccount in class PrincipalBase