-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathupdate-user.js
More file actions
29 lines (23 loc) · 812 Bytes
/
update-user.js
File metadata and controls
29 lines (23 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { fileURLToPath } from "node:url";
// snippet-start:[iam.JavaScript.users.updateUserV3]
import { UpdateUserCommand, IAMClient } from "@aws-sdk/client-iam";
const client = new IAMClient({});
/**
*
* @param {string} currentUserName
* @param {string} newUserName
*/
export const updateUser = (currentUserName, newUserName) => {
const command = new UpdateUserCommand({
UserName: currentUserName,
NewUserName: newUserName,
});
return client.send(command);
};
// snippet-end:[iam.JavaScript.users.updateUserV3]
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
updateUser("CURRENT_USER_NAME", "NEW_USER_NAME");
}