IRole
- class aws_cdk.aws_iam.IRole(*args, **kwargs)
Bases:
IIdentity
,Protocol
A Role object.
Methods
- add_managed_policy(policy)
Attaches a managed policy to this principal.
- Parameters:
policy (
IManagedPolicy
) – The managed policy.- Return type:
None
- 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:
- apply_removal_policy(policy)
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
RemovalPolicy
)- Return type:
None
- attach_inline_policy(policy)
Attaches an inline policy to this principal.
This is the same as calling
policy.addToXxx(principal)
.- Parameters:
policy (
Policy
) – The policy resource to attach to this principal [disable-awslint:ref-via-interface].- Return type:
None
- grant(grantee, *actions)
Grant the actions defined in actions to the identity Principal on this resource.
- Parameters:
grantee (
IPrincipal
)actions (
str
)
- Return type:
- grant_assume_role(grantee)
Grant permissions to the given principal to assume this role.
- Parameters:
grantee (
IPrincipal
)- Return type:
- grant_pass_role(grantee)
Grant permissions to the given principal to pass this role.
- Parameters:
grantee (
IPrincipal
)- Return type:
Attributes
- assume_role_action
When this Principal is used in an AssumeRole policy, the action to use.
- env
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
- grant_principal
The principal to grant permissions to.
- node
The construct tree node for this construct.
- policy_fragment
Return the policy fragment that identifies this principal in a Policy.
- 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.
- role_arn
Returns the ARN of this role.
- Attribute:
true
- role_name
Returns the name of this role.
- Attribute:
true
- stack
The stack in which this resource is defined.