View a markdown version of this page

获取配置包 - Amazon Bedrock AgentCore

获取配置包

检索配置包以检查其元数据或读取特定版本的完整配置内容。有两种操作可供选择:

  • GetConfigurationBundle— 返回最新版本的捆绑包。如果指定,branchName则返回该分支上的最新版本。如果省略,则返回所有分支的最新版本。使用它来读取当前的活动配置。

  • GetConfigurationBundleVersion— 按版本 ID 返回特定的历史版本。使用它来检查过去的配置或比较版本。

捆绑包元数据与版本内容

GetConfigurationBundle返回捆绑包级别的元数据(名称、描述、ARN)和完整版本内容(带有配置键值对的组件)。如果您只需要知道存在哪些版本而不获取其全部内容,请ListConfigurationBundleVersions改用。

GetConfigurationBundleVersion返回相同的字段 plusversionCreatedAt,它会准确地告诉你该特定版本的创建时间(而不是最初创建捆绑包本身的时间)。createdAt

代码示例

AgentCore CLI

查看捆绑包的版本历史记录:

agentcore config-bundle versions --name myAgentConfig

并排比较两个版本:

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

没有直接的 “获取捆绑包内容” CLI 命令—— config-bundle 子命令是versionsdiff、和create-branch。要枚举版本并捕获其 ID,请使用agentcore config-bundle versions --name myAgentConfig --json(可选择使用--branch <name>--latest-per-branch、或--created-by <name>),然后将版本 ID 输入到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

字符串

配置包的 ID。作为路径参数传递。

branchName

字符串

要从中获取最新版本的分支名称。如果省略,则返回所有分支的最新版本。

GetConfigurationBundleVersion

参数 Type 必需 描述

bundleId

字符串

配置包的 ID。作为路径参数传递。

versionId

字符串

要检索的特定版本的 UUID。作为路径参数传递。

响应

这两个操作都返回相同的字段。 GetConfigurationBundleVersion另外还会返回versionCreatedAt

字段 Type 说明

bundleArn

字符串

配置包的 ARN。

bundleId

字符串

配置包的 ID。

bundleName

字符串

捆绑包的名称。

description

字符串

捆绑包的描述(如果已设置)。

versionId

字符串

返回的版本的 UUID。

components

Map

组件标识符到组件配置的映射。每个值都包含一个configuration对象,其键值对存储在此版本中。

lineageMetadata

对象

版本谱系元数据包括parentVersionIdsbranchNamecreatedBy、和。commitMessage

createdAt

Timestamp

最初创建捆绑包的时间。

updatedAt

Timestamp

捆绑包上次更新时间(GetConfigurationBundle 仅限)。

versionCreatedAt

Timestamp

此特定版本的创建时间(GetConfigurationBundleVersion 仅限)。

错误

错误 HTTP 状态 说明

ValidationException

400

请求参数无效。

ResourceNotFoundException

404

指定的bundleIdversionId不存在。

AccessDeniedException

403

权限不足。验证 IAM 策略是否包含bedrock-agentcore:GetConfigurationBundlebedrock-agentcore:GetConfigurationBundleVersion

ThrottlingException

429

超出请求速率。使用指数回退进行重试。

InternalServerException

500

Service-side 错误。重试请求。