IPrincipal

class aws_cdk.aws_iam.IPrincipal(*args, **kwds)

Bases: aws_cdk.aws_iam.IGrantable, typing_extensions.Protocol

Represents a logical IAM principal.

An IPrincipal describes a logical entity that can perform AWS API calls against sets of resources, optionally under certain conditions.

Examples of simple principals are IAM objects that you create, such as Users or Roles.

An example of a more complex principals is a ServicePrincipal (such as new ServicePrincipal("sns.amazonaws.com"), which represents the Simple Notifications Service).

A single logical Principal may also map to a set of physical principals. For example, new OrganizationPrincipal('o-1234') represents all identities that are part of the given AWS Organization.

Methods

add_to_policy(statement)

(deprecated) Add to the policy of this principal.

Parameters

statement (PolicyStatement) –

Return type

bool

Returns

true if the statement was added, false if the principal in question does not have a policy document to add the statement to.

Deprecated

Use addToPrincipalPolicy instead.

Stability

deprecated

add_to_principal_policy(statement)

Add to the policy of this principal.

Parameters

statement (PolicyStatement) –

Return type

AddToPrincipalPolicyResult

Attributes

assume_role_action

When this Principal is used in an AssumeRole policy, the action to use.

Return type

str

grant_principal

The principal to grant permissions to.

Return type

IPrincipal

policy_fragment

Return the policy fragment that identifies this principal in a Policy.

Return type

PrincipalPolicyFragment

principal_account

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.

Return type

Optional[str]