- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
UpdateUserCommand
Updates the name and/or the path of the specified IAM user.
You should understand the implications of changing an IAM user's path or name. For more information, see Renaming an IAM user and Renaming an IAM group in the IAM User Guide.
To change a user name, the requester must have appropriate permissions on both the source object and the target object. For example, to change Bob to Robert, the entity making the request must have permission on Bob and Robert, or must have permission on all (*). For more information about permissions, see Permissions and policies .
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { IAMClient, UpdateUserCommand } from "@aws-sdk/client-iam"; // ES Modules import
// const { IAMClient, UpdateUserCommand } = require("@aws-sdk/client-iam"); // CommonJS import
const client = new IAMClient(config);
const input = { // UpdateUserRequest
UserName: "STRING_VALUE", // required
NewPath: "STRING_VALUE",
NewUserName: "STRING_VALUE",
};
const command = new UpdateUserCommand(input);
const response = await client.send(command);
// {};
Example Usage
UpdateUserCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
UserName Required | string | undefined | Name of the user to update. If you're changing the name of the user, this is the original user name. This parameter allows (through its regex pattern ) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.- |
NewPath | string | undefined | New path for the IAM user. Include this parameter only if you're changing the user's path. This parameter allows (through its regex pattern ) a string of characters consisting of either a forward slash (/) by itself or a string that must begin and end with forward slashes. In addition, it can contain any ASCII character from the ! ( |
NewUserName | string | undefined | New name for the user. Include this parameter only if you're changing the user's name. IAM user, group, role, and policy names must be unique within the account. Names are not distinguished by case. For example, you cannot create resources named both "MyResource" and "myresource". |
UpdateUserCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
ConcurrentModificationException | client | The request was rejected because multiple requests to change this object were submitted simultaneously. Wait a few minutes and submit your request again. |
EntityAlreadyExistsException | client | The request was rejected because it attempted to create a resource that already exists. |
EntityTemporarilyUnmodifiableException | client | The request was rejected because it referenced an entity that is temporarily unmodifiable, such as a user name that was deleted and then recreated. The error indicates that the request is likely to succeed if you try again after waiting several minutes. The error message describes the entity. |
LimitExceededException | client | The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded. |
NoSuchEntityException | client | The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource. |
ServiceFailureException | server | The request processing has failed because of an unknown error, exception or failure. |
IAMServiceException | Base exception class for all service exceptions from IAM service. |