View a markdown version of this page

取得組態套件 - Amazon Bedrock AgentCore

取得組態套件

擷取組態套件以檢查其中繼資料或讀取特定版本的完整組態內容。有兩個可用的操作:

  • GetConfigurationBundle — 傳回套件的最新版本。如果指定 branchName , 會傳回該分支的最新版本。如果省略, 會傳回所有分支的最新版本。使用此項目可讀取目前的作用中組態。

  • GetConfigurationBundleVersion — 依版本 ID 傳回特定歷史版本。使用此項目來檢查過去的組態或比較版本。

套件中繼資料與版本內容

GetConfigurationBundle 會同時傳回套件層級中繼資料 (名稱、描述、ARN) 和完整版本內容 (具有其組態金鑰/值對的元件)。如果您只需要知道哪些版本存在,而不擷取其完整內容,請ListConfigurationBundleVersions改用 。

GetConfigurationBundleVersion 會傳回相同的欄位加上 versionCreatedAt,告訴您確切建立該特定版本的時間 (而不是 createdAt,也就是第一次建立套件本身的時間)。

程式碼範例

範例
AgentCore CLI

檢視套件的版本歷史記錄:

agentcore config-bundle versions --name myAgentConfig

並排比較兩個版本:

agentcore config-bundle diff --name myAgentConfig \ --from <version-1> \ --to <version-2>
注意

沒有直接的「取得套件內容」CLI 命令 — config-bundle子命令為 versionsdiffcreate-branch。若要列舉版本並擷取其 IDs,請使用 agentcore config-bundle versions --name myAgentConfig --json(選用搭配 --branch <name>、 或 --created-by <name>)--latest-per-branch,然後將版本 IDs 饋送至 config-bundle diff。若要擷取套件版本的完整組態內容,請使用如下所示的 SDK/REST GetConfigurationBundleVersion操作。

AWS SDK (boto3)

取得套件中繼資料和最新版本內容:

import boto3 client = boto3.client("bedrock-agentcore-control", region_name="us-west-2") response = client.get_configuration_bundle( bundleId="myAgentConfig-a1b2c3d4e5" ) print(f"Bundle: {response['bundleName']}") print(f"Version: {response['versionId']}") print(f"Branch: {response.get('lineageMetadata', {}).get('branchName', 'N/A')}") print(f"Components: {response['components']}")

取得特定歷史版本:

response = client.get_configuration_bundle_version( bundleId="myAgentConfig-a1b2c3d4e5", versionId="12345678-1234-1234-1234-123456789012" ) print(f"Version: {response['versionId']}") print(f"Version created at: {response['versionCreatedAt']}") print(f"Commit message: {response.get('lineageMetadata', {}).get('commitMessage', '')}") print(f"Components: {response['components']}")

請求參數

GetConfigurationBundle

參數 Type 必要 描述

bundleId

String

組態套件的 ID。以路徑參數傳遞。

branchName

String

要從中取得最新版本的分支名稱。如果省略, 會傳回所有分支的最新版本。

GetConfigurationBundleVersion

參數 Type 必要 描述

bundleId

String

組態套件的 ID。以路徑參數傳遞。

versionId

String

要擷取之特定版本的 UUID。以路徑參數傳遞。

回應

這兩個操作都會傳回相同的欄位。 GetConfigurationBundleVersion也會傳回 versionCreatedAt

欄位 Type Description

bundleArn

String

組態套件的 ARN。

bundleId

String

組態套件的 ID。

bundleName

String

套件的名稱。

description

String

套件的描述 (如果設定)。

versionId

String

傳回的 版本的 UUID。

components

Map

元件識別符與元件組態的映射。每個值都包含一個configuration物件,其中包含存放在此版本中的鍵值對。

lineageMetadata

物件

版本歷程中繼資料,包括 parentVersionIdscreatedBybranchNamecommitMessage

createdAt

時間戳記

原始建立套件的時間。

updatedAt

時間戳記

套件上次更新的時間 (僅限 GetConfigurationBundle)。

versionCreatedAt

時間戳記

建立此特定版本時 (僅限 GetConfigurationBundleVersion)。

錯誤

錯誤 HTTP 狀態 說明

ValidationException

400

無效的請求參數。

ResourceNotFoundException

404

指定的 bundleIdversionId 不存在。

AccessDeniedException

403

許可不足。驗證 IAM 政策包含 bedrock-agentcore:GetConfigurationBundlebedrock-agentcore:GetConfigurationBundleVersion

ThrottlingException

429

超過請求率。以指數退避重試。

InternalServerException

500

服務端錯誤。重試 請求。