View a markdown version of this page

建立和管理工作負載身分 - Amazon Bedrock AgentCore

建立和管理工作負載身分

您可以根據您的工作流程和整合需求,使用多種方法來建立客服人員身分,包括 AWS CLI 和 AgentCore SDK。AgentCore Identity 提供多個介面來建立身分,包括用於自動化和指令碼編寫的命令列工具,以及用於與現有系統整合APIs。每個建立方法都支援完整的身分屬性範圍,同時為不同的使用案例和使用者偏好設定提供適當的界面。

使用 CLI AWS 管理身分

CLI AWS 提供簡單的方法來建立和刪除客服人員身分。

建立身分

下列命令會建立名為 my-agent 的工作負載身分。

aws bedrock-agentcore-control create-workload-identity \ --name "my-agent"

列出所有身分

下列命令會列出您帳戶中的所有工作負載身分。

aws bedrock-agentcore-control list-workload-identities

刪除身分

下列命令會刪除名為 my-agent 的工作負載身分。

aws bedrock-agentcore-control delete-workload-identity \ --name "my-agent"

使用 AgentCore SDK 建立身分

AgentCore SDK 支援在 Python 中建立工作負載身分。

Python 範例

下列 Python 程式碼會使用 AgentCore SDK 建立工作負載身分。

from bedrock_agentcore.services.identity import IdentityClient # Initialize the client identity_client = IdentityClient("us-east-1") # Create a new workload identity for agent response = identity_client.create_workload_identity(name='my-python-agent') agentArn = response['workloadIdentityArn'] print(f"Created agent identity with ARN: {agentArn}")