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.116.0 (build 0eddcff)",
date="2025-10-29T11:15:41.239Z")
@Stability(Stable)
public class ServicePrincipal
extends PrincipalBase
An IAM principal that represents an AWS service (i.e.
sqs.amazonaws.com).
Example:
IChainable definition;
Role role = Role.Builder.create(this, "Role")
.assumedBy(new ServicePrincipal("lambda.amazonaws.com"))
.build();
StateMachine stateMachine = StateMachine.Builder.create(this, "StateMachine")
.definitionBody(DefinitionBody.fromChainable(definition))
.build();
// Give role permission to get execution history of ALL executions for the state machine
stateMachine.grantExecution(role, "states:GetExecutionHistory");
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.iam.IAssumeRolePrincipal
IAssumeRolePrincipal.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.iam.IComparablePrincipal
IComparablePrincipal.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionServicePrincipal(String service) Reference an AWS service, optionally in a given region.ServicePrincipal(String service, ServicePrincipalOpts opts) Reference an AWS service, optionally in a given region.protectedServicePrincipal(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedServicePrincipal(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionReturn whether or not this principal is equal to the given principal.static ServicePrincipalfromStaticServicePrincipleName(String servicePrincipalName) Return the service principal using the service principal name as it is passed to the function without any change regardless of the region used in the stack if it is Opted in or not.Return the policy fragment that identifies this principal in a Policy.AWS service (i.e.static StringservicePrincipalName(String service) Return the service principal name based on the region it's used in.toString()Returns a string representation of an object.Methods inherited from class software.amazon.awscdk.services.iam.PrincipalBase
addToAssumeRolePolicy, addToPolicy, addToPrincipalPolicy, getAssumeRoleAction, getGrantPrincipal, getPrincipalAccount, toJSON, withConditions, withSessionTagsMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
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) Reference an AWS service, optionally in a given region.- Parameters:
service- AWS service (i.e. sqs.amazonaws.com). This parameter is required.opts-
-
ServicePrincipal
Reference an AWS service, optionally in a given region.- Parameters:
service- AWS service (i.e. sqs.amazonaws.com). This parameter is required.
-
-
Method Details
-
fromStaticServicePrincipleName
@Stability(Stable) @NotNull public static ServicePrincipal fromStaticServicePrincipleName(@NotNull String servicePrincipalName) Return the service principal using the service principal name as it is passed to the function without any change regardless of the region used in the stack if it is Opted in or not.Example:
ServicePrincipal principalName = ServicePrincipal.fromStaticServicePrincipleName("elasticmapreduce.amazonaws.com.rproxy.goskope.com.cn");- Parameters:
servicePrincipalName- This parameter is required.
-
servicePrincipalName
Return the service principal name based on the region it's used in.Some service principal names used to be different for different partitions, and some were not. This method would return the appropriate region-specific service principal name, getting that information from the
region-infomodule.These days all service principal names are standardized, and they are all of the form
<servicename>.amazonaws.com.rproxy.goskope.com.To avoid breaking changes, handling is provided for services added with the formats below, however, no additional handling will be added for new regions or partitions.
- s3
- s3.amazonaws.com
- s3.amazonaws.com.rproxy.goskope.com.cn
- s3.c2s.ic.gov
- s3.sc2s.sgov.gov
Example:
String principalName = ServicePrincipal.servicePrincipalName("ec2.amazonaws.com");- Parameters:
service- This parameter is required.
-
dedupeString
Return whether or not this principal is equal to the given principal.- Specified by:
dedupeStringin interfaceIComparablePrincipal- Specified by:
dedupeStringin classPrincipalBase
-
toString
Returns a string representation of an object.- Overrides:
toStringin classPrincipalBase
-
getPolicyFragment
Return the policy fragment that identifies this principal in a Policy.- Specified by:
getPolicyFragmentin interfaceIPrincipal- Specified by:
getPolicyFragmentin classPrincipalBase
-
getService
AWS service (i.e. sqs.amazonaws.com).
-