Class ServicePrincipal

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

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:29:57.374Z") @Stability(Stable) public class ServicePrincipal extends PrincipalBase
An IAM principal that represents an AWS service (i.e. sqs.amazonaws.com).

Example:

 Role lambdaRole = Role.Builder.create(this, "Role")
         .assumedBy(new ServicePrincipal("lambda.amazonaws.com"))
         .description("Example role...")
         .build();
 Stream stream = Stream.Builder.create(this, "MyEncryptedStream")
         .encryption(StreamEncryption.KMS)
         .build();
 // give lambda permissions to read stream
 stream.grantRead(lambdaRole);
 
  • Constructor Details

    • ServicePrincipal

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

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

      @Stability(Stable) public ServicePrincipal(@NotNull String service, @Nullable ServicePrincipalOpts opts)
      Parameters:
      service - AWS service (i.e. sqs.amazonaws.com). This parameter is required.
      opts -
    • ServicePrincipal

      @Stability(Stable) public ServicePrincipal(@NotNull String service)
      Parameters:
      service - AWS service (i.e. sqs.amazonaws.com). This parameter is required.
  • Method Details

    • servicePrincipalName

      @Stability(Stable) @NotNull public static String servicePrincipalName(@NotNull String service)
      Translate the given service principal name based on the region it's used in.

      For example, for Chinese regions this may (depending on whether that's necessary for the given service principal) append .cn to the name.

      The region-info module is used to obtain this information.

      Example:

       String principalName = ServicePrincipal.servicePrincipalName("ec2.amazonaws.com");
       

      Parameters:
      service - 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
    • 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
    • getService

      @Stability(Stable) @NotNull public String getService()
      AWS service (i.e. sqs.amazonaws.com).