interface IUser
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.IAM.IUser |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsiam#IUser |
Java | software.amazon.awscdk.services.iam.IUser |
Python | aws_cdk.aws_iam.IUser |
TypeScript (source) | aws-cdk-lib » aws_iam » IUser |
Implemented by
User
Obtainable from
User
.fromUserArn()
, User
.fromUserAttributes()
, User
.fromUserName()
Represents an IAM user.
See also: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html
Properties
Name | Type | Description |
---|---|---|
assume | string | When this Principal is used in an AssumeRole policy, the action to use. |
env | Resource | The environment this resource belongs to. |
grant | IPrincipal | The principal to grant permissions to. |
node | Node | The tree node. |
policy | Principal | Return the policy fragment that identifies this principal in a Policy. |
stack | Stack | The stack in which this resource is defined. |
user | string | The user's ARN. |
user | string | The user's name. |
principal | string | The AWS account ID of this principal. |
assumeRoleAction
Type:
string
When this Principal is used in an AssumeRole policy, the action to use.
env
Type:
Resource
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.
grantPrincipal
Type:
IPrincipal
The principal to grant permissions to.
node
Type:
Node
The tree node.
policyFragment
Type:
Principal
Return the policy fragment that identifies this principal in a Policy.
stack
Type:
Stack
The stack in which this resource is defined.
userArn
Type:
string
The user's ARN.
userName
Type:
string
The user's name.
principalAccount?
Type:
string
(optional)
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.
Methods
Name | Description |
---|---|
add | Attaches a managed policy to this principal. |
add | Adds this user to a group. |
add | Add to the policy of this principal. |
apply | Apply the given removal policy to this resource. |
attach | Attaches an inline policy to this principal. |
ManagedPolicy(policy)
addpublic addManagedPolicy(policy: IManagedPolicy): void
Parameters
- policy
IManaged
— The managed policy.Policy
Attaches a managed policy to this principal.
ToGroup(group)
addpublic addToGroup(group: IGroup): void
Parameters
- group
IGroup
Adds this user to a group.
ToPrincipalPolicy(statement)
addpublic addToPrincipalPolicy(statement: PolicyStatement): AddToPrincipalPolicyResult
Parameters
- statement
Policy
Statement
Returns
Add to the policy of this principal.
RemovalPolicy(policy)
applypublic applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
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
).
InlinePolicy(policy)
attachpublic attachInlinePolicy(policy: Policy): void
Parameters
- policy
Policy
— The policy resource to attach to this principal [disable-awslint:ref-via-interface].
Attaches an inline policy to this principal.
This is the same as calling policy.addToXxx(principal)
.