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:
IUserRef,IEnvironmentAware,IResource,IGrantable,IIdentity,IPrincipal,IUser,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.119.0 (build 1634eac)",
date="2025-11-13T16:10:07.251Z")
@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 ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.iam.IIdentity
IIdentity.Jsii$Default, IIdentity.Jsii$ProxyNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.iam.IUser
IUser.Jsii$Default, IUser.Jsii$Proxy -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddManagedPolicy(IManagedPolicy policy) Attaches a managed policy to the user.voidaddToGroup(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.voidattachInlinePolicy(Policy policy) Attaches a policy to this user.static IUserfromUserArn(software.constructs.Construct scope, String id, String userArn) Import an existing user given a user ARN.static IUserfromUserAttributes(software.constructs.Construct scope, String id, UserAttributes attrs) Import an existing user given user attributes.static IUserfromUserName(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.A reference to a User resource.Methods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourceMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
PROPERTY_INJECTION_ID
Uniquely identifies this class.
-
-
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:
addManagedPolicyin interfaceIIdentity- Parameters:
policy- The managed policy to attach. This parameter is required.
-
addToGroup
Adds this user to a group.- Specified by:
addToGroupin 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:
addToPrincipalPolicyin interfaceIPrincipal- Parameters:
statement- This parameter is required.- Returns:
- true
-
attachInlinePolicy
Attaches a policy to this user.- Specified by:
attachInlinePolicyin interfaceIIdentity- Parameters:
policy- This parameter is required.
-
getAssumeRoleAction
When this Principal is used in an AssumeRole policy, the action to use.- Specified by:
getAssumeRoleActionin interfaceIPrincipal
-
getGrantPrincipal
The principal to grant permissions to.- Specified by:
getGrantPrincipalin interfaceIGrantable
-
getPolicyFragment
Return the policy fragment that identifies this principal in a Policy.- Specified by:
getPolicyFragmentin interfaceIPrincipal
-
getUserArn
An attribute that represents the user's ARN.- Specified by:
getUserArnin interfaceIUser
-
getUserName
An attribute that represents the user name.- Specified by:
getUserNamein interfaceIUser
-
getUserRef
A reference to a User resource.- Specified by:
getUserRefin interfaceIUserRef
-
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:
getPrincipalAccountin interfaceIPrincipal
-