Class CompositePrincipal

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

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-17T05:10:12.059Z") @Stability(Stable) public class CompositePrincipal extends PrincipalBase
Represents a principal that has multiple types of principals.

A composite principal cannot have conditions. i.e. multiple ServicePrincipals that form a composite principal

Example:

 Vpc vpc;
 Role role = Role.Builder.create(this, "RDSDirectoryServicesRole")
         .assumedBy(new CompositePrincipal(
         new ServicePrincipal("rds.amazonaws.com"),
         new ServicePrincipal("directoryservice.rds.amazonaws.com")))
         .managedPolicies(List.of(ManagedPolicy.fromAwsManagedPolicyName("service-role/AmazonRDSDirectoryServiceAccess")))
         .build();
 DatabaseInstance instance = DatabaseInstance.Builder.create(this, "Instance")
         .engine(DatabaseInstanceEngine.mysql(MySqlInstanceEngineProps.builder().version(MysqlEngineVersion.VER_8_0_19).build()))
         .vpc(vpc)
         .domain("d-????????") // The ID of the domain for the instance to join.
         .domainRole(role)
         .build();
 
  • Constructor Details

    • CompositePrincipal

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

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

      @Stability(Stable) public CompositePrincipal(@NotNull @NotNull IPrincipal... principals)
      Parameters:
      principals - This parameter is required.
  • Method Details

    • addPrincipals

      @Stability(Stable) @NotNull public CompositePrincipal addPrincipals(@NotNull @NotNull IPrincipal... principals)
      Adds IAM principals to the composite principal.

      Composite principals cannot have conditions.

      Parameters:
      principals - IAM principals that will be added to the composite principal. 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.
    • 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
    • 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
    • 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
    • getPrincipals

      @Stability(Stable) @NotNull public List<IPrincipal> getPrincipals()
      Returns the principals that make up the CompositePrincipal.