-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathupdate-access-key.js
More file actions
34 lines (28 loc) · 863 Bytes
/
update-access-key.js
File metadata and controls
34 lines (28 loc) · 863 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
30
31
32
33
34
// 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.keys.updateAccessKeyV3]
import {
UpdateAccessKeyCommand,
IAMClient,
StatusType,
} from "@aws-sdk/client-iam";
const client = new IAMClient({});
/**
*
* @param {string} userName
* @param {string} accessKeyId
*/
export const updateAccessKey = (userName, accessKeyId) => {
const command = new UpdateAccessKeyCommand({
AccessKeyId: accessKeyId,
Status: StatusType.Inactive,
UserName: userName,
});
return client.send(command);
};
// snippet-end:[iam.JavaScript.keys.updateAccessKeyV3]
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
updateAccessKey("USER_NAME", "ACCESS_KEY_ID");
}