-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Expand file tree
/
Copy pathdelete-agent.js
More file actions
40 lines (32 loc) · 1.41 KB
/
delete-agent.js
File metadata and controls
40 lines (32 loc) · 1.41 KB
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
35
36
37
38
39
40
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import { fileURLToPath } from "node:url";
import { checkForPlaceholders } from "../lib/utils.js";
import {
BedrockAgentClient,
DeleteAgentCommand,
} from "@aws-sdk/client-bedrock-agent";
/**
* Deletes an Amazon Bedrock Agent.
*
* @param {string} agentId - The unique identifier of the agent to delete.
* @param {string} [region='us-east-1'] - The AWS region in use.
* @returns {Promise<import("@aws-sdk/client-bedrock-agent").DeleteAgentCommandOutput>} An object containing the agent id, the status, and some additional metadata.
*/
export const deleteAgent = (agentId, region = "us-east-1") => {
const client = new BedrockAgentClient({ region });
const command = new DeleteAgentCommand({ agentId });
return client.send(command);
};
// Invoke main function if this file was run directly.
if (process.argv[1] === fileURLToPath(import.meta.url)) {
// Replace the placeholders for agentId with an existing agent's id.
// Ensure to remove the brackets (`[]`) before adding your data.
// The agentId must be an alphanumeric string with exactly 10 characters.
const agentId = "[ABC123DE45]";
// Check for unresolved placeholders in agentId.
checkForPlaceholders([agentId]);
console.log(`Deleting agent with ID ${agentId}...`);
const response = await deleteAgent(agentId);
console.log(response);
}