Class User
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.iam.User
- All Implemented Interfaces:
IResource
,IGrantable
,IIdentity
,IPrincipal
,IUser
,software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)",
date="2024-10-11T15:56:00.051Z")
@Stability(Stable)
public class User
extends Resource
implements IIdentity, IUser
Define a new IAM user.
Example:
IChainable definition; User user = new User(this, "MyUser"); StateMachine stateMachine = StateMachine.Builder.create(this, "StateMachine") .definitionBody(DefinitionBody.fromChainable(definition)) .build(); //give user permission to send task success to the state machine stateMachine.grant(user, "states:SendTaskSuccess");
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
Nested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.iam.IIdentity
IIdentity.Jsii$Default, IIdentity.Jsii$Proxy
Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default
Nested classes/interfaces inherited from interface software.amazon.awscdk.services.iam.IUser
IUser.Jsii$Default, IUser.Jsii$Proxy
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addManagedPolicy
(IManagedPolicy policy) Attaches a managed policy to the user.void
addToGroup
(IGroup group) Adds this user to a group.addToPolicy
(PolicyStatement statement) Add to the policy of this principal.addToPrincipalPolicy
(PolicyStatement statement) Adds an IAM statement to the default policy.void
attachInlinePolicy
(Policy policy) Attaches a policy to this user.static IUser
fromUserArn
(software.constructs.Construct scope, String id, String userArn) Import an existing user given a user ARN.static IUser
fromUserAttributes
(software.constructs.Construct scope, String id, UserAttributes attrs) Import an existing user given user attributes.static IUser
fromUserName
(software.constructs.Construct scope, String id, String userName) Import an existing user given a username.When this Principal is used in an AssumeRole policy, the action to use.The principal to grant permissions to.Returns the permissions boundary attached to this user.Return the policy fragment that identifies this principal in a Policy.The AWS account ID of this principal.An attribute that represents the user's ARN.An attribute that represents the user name.Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResource
Methods inherited from class software.constructs.Construct
getNode, isConstruct, toString
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface software.constructs.IConstruct
getNode
Methods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStack
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
User
protected User(software.amazon.jsii.JsiiObjectRef objRef) -
User
protected User(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
User
@Stability(Stable) public User(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable UserProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
-
-
User
- Parameters:
scope
- This parameter is required.id
- This parameter is required.
-
-
Method Details
-
fromUserArn
@Stability(Stable) @NotNull public static IUser fromUserArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String userArn) Import an existing user given a user ARN.If the ARN comes from a Token, the User cannot have a path; if so, any attempt to reference its username will fail.
- Parameters:
scope
- construct scope. This parameter is required.id
- construct id. This parameter is required.userArn
- the ARN of an existing user to import. This parameter is required.
-
fromUserAttributes
@Stability(Stable) @NotNull public static IUser fromUserAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull UserAttributes attrs) Import an existing user given user attributes.If the ARN comes from a Token, the User cannot have a path; if so, any attempt to reference its username will fail.
- Parameters:
scope
- construct scope. This parameter is required.id
- construct id. This parameter is required.attrs
- the attributes of the user to import. This parameter is required.
-
fromUserName
@Stability(Stable) @NotNull public static IUser fromUserName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String userName) Import an existing user given a username.- Parameters:
scope
- construct scope. This parameter is required.id
- construct id. This parameter is required.userName
- the username of the existing user to import. This parameter is required.
-
addManagedPolicy
Attaches a managed policy to the user.- Specified by:
addManagedPolicy
in interfaceIIdentity
- Parameters:
policy
- The managed policy to attach. This parameter is required.
-
addToGroup
Adds this user to a group.- Specified by:
addToGroup
in interfaceIUser
- Parameters:
group
- This parameter is required.
-
addToPolicy
Add to the policy of this principal.- Parameters:
statement
- This parameter is required.
-
addToPrincipalPolicy
@Stability(Stable) @NotNull public AddToPrincipalPolicyResult addToPrincipalPolicy(@NotNull PolicyStatement statement) Adds an IAM statement to the default policy.- Specified by:
addToPrincipalPolicy
in interfaceIPrincipal
- Parameters:
statement
- This parameter is required.- Returns:
- true
-
attachInlinePolicy
Attaches a policy to this user.- Specified by:
attachInlinePolicy
in interfaceIIdentity
- Parameters:
policy
- This parameter is required.
-
getAssumeRoleAction
When this Principal is used in an AssumeRole policy, the action to use.- Specified by:
getAssumeRoleAction
in interfaceIPrincipal
-
getGrantPrincipal
The principal to grant permissions to.- Specified by:
getGrantPrincipal
in interfaceIGrantable
-
getPolicyFragment
Return the policy fragment that identifies this principal in a Policy.- Specified by:
getPolicyFragment
in interfaceIPrincipal
-
getUserArn
An attribute that represents the user's ARN.- Specified by:
getUserArn
in interfaceIUser
-
getUserName
An attribute that represents the user name.- Specified by:
getUserName
in interfaceIUser
-
getPermissionsBoundary
Returns the permissions boundary attached to this user. -
getPrincipalAccount
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.
- Specified by:
getPrincipalAccount
in interfaceIPrincipal
-