Class ServicePrincipal
An IAM principal that represents an AWS service (i.e. sqs.amazonaws.com).
public class ServicePrincipal : PrincipalBase, IAssumeRolePrincipal, IComparablePrincipal, IPrincipal, IGrantable
- Inheritance
-
ServicePrincipal
- Implements
- Inherited Members
Examples
var lambdaRole = new Role(this, "Role", new RoleProps {
AssumedBy = new ServicePrincipal("lambda.amazonaws.com"),
Description = "Example role..."
});
var stream = new Stream(this, "MyEncryptedStream", new StreamProps {
Encryption = StreamEncryption.KMS
});
// give lambda permissions to read stream
stream.GrantRead(lambdaRole);
Remarks
ExampleMetadata: infused
Constructors
ServicePrincipal(string, IServicePrincipalOpts?)
public ServicePrincipal(string service, IServicePrincipalOpts? opts = null)
Parameters
service
stringAWS service (i.e. sqs.amazonaws.com).
opts
IServicePrincipalOpts
Properties
PolicyFragment
Return the policy fragment that identifies this principal in a Policy.
public override PrincipalPolicyFragment PolicyFragment { get; }
Property Value
Service
AWS service (i.e. sqs.amazonaws.com).
public virtual string Service { get; }
Property Value
Methods
DedupeString()
Return whether or not this principal is equal to the given principal.
public override string? DedupeString()
Returns
ServicePrincipalName(string)
Translate the given service principal name based on the region it's used in.
public static string ServicePrincipalName(string service)
Parameters
service
string
Returns
Examples
var principalName = ServicePrincipal.ServicePrincipalName("ec2.amazonaws.com");
Remarks
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.
ToString()
Returns a string representation of an object.
public override string ToString()