

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 创建配置包
<a name="configuration-bundles-create"></a>

创建配置包以存储代理动态配置的版本化快照。该捆绑包是在`mainline`分支上使用初始版本创建的。

**注意**  
CLI `add config-bundle` 命令将包定义保存到`agentcore.json`本地。要在服务上实际创建它，你必须在`agentcore deploy`之后运行。

## 代码示例
<a name="create-bundle-examples"></a>

**Example**  
使用内联组件 JSON 创建，然后部署：  

```
agentcore add config-bundle \
  --name myAgentConfig \
  --description "Initial config" \
  --branch mainline \
  --commit-message "Initial bundle creation" \
  --components '{"arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/MyAgent-abc123": {"configuration": {"system_prompt": "You are a helpful assistant.", "model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0"}}}'

agentcore deploy
```
`--components`密钥可以是 ARN 或以或形式`{{runtime:<name>}}`表示的占位符。`{{gateway:<name>}}`占位符在部署时解析为真实的 ARN，因此对于项目中管理的资源，请使用占位符表单。原始 ARN 密钥要求资源已经存在：  

```
agentcore add config-bundle \
  --name myAgentConfig \
  --components '{"{{runtime:MyAgent}}": {"configuration": {"system_prompt": "You are a helpful assistant."}}}'

agentcore deploy
```
添加`--description``--branch`、和`--commit-message`以设置版本元数据，或`--json`将结果输出为 JSON。  
从组件文件创建，然后部署：  

```
agentcore add config-bundle \
  --name myAgentConfig \
  --components-file ./components.json

agentcore deploy
```
示例`components.json`：  

```
{
    "arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/MyAgent-abc123": {
        "configuration": {
            "system_prompt": "You are a helpful customer support assistant for Acme Store. When handling requests: 1) Identify ALL actions needed before starting any. 2) Execute each action in sequence. 3) Before ending any conversation, summarize what was done.",
            "model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0"
        }
    }
}
```

```
import boto3
import uuid

client = boto3.client("bedrock-agentcore-control", region_name="us-west-2")

RUNTIME_ARN = "arn:aws:bedrock-agentcore:us-west-2:123456789012:runtime/MyAgent-abc123"

response = client.create_configuration_bundle(
    bundleName="myAgentConfig",
    components={
        RUNTIME_ARN: {
            "configuration": {
                "system_prompt": "You are a helpful customer support assistant.",
                "model_id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
                "temperature": 0.7,
            }
        }
    },
    description="Initial configuration for MyAgent",
    branchName="mainline",
    commitMessage="Initial bundle creation",
    clientToken=str(uuid.uuid4()),
)

print(f"Bundle ID: {response['bundleId']}")
print(f"Bundle ARN: {response['bundleArn']}")
print(f"Version ID: {response['versionId']}")
```

## 请求参数
<a name="create-bundle-params"></a>


| 参数 | Type | 必需 | 描述 | 
| --- | --- | --- | --- | 
|  `bundleName`  | 字符串 | 是 | 捆绑包的名称。必须匹配`[a-zA-Z][a-zA-Z0-9_]{0,99}`。您的账户中的姓名必须是唯一的。 | 
|  `components`  | Map | 是 | 组件标识符映射到组件配置。密钥通常是正在配置的 AgentCore 资源的 ARN（例如，运行时 ARN）。每个值都包含一个具有任意键值对的`configuration`对象。 | 
|  `description`  | 字符串 | 否 | 捆绑包的描述。最多 500 个字符。 | 
|  `branchName`  | 字符串 | 否 | 用于版本跟踪的分支名称。默认值为 `mainline`。必须匹配`[a-zA-Z][a-zA-Z0-9_/-]{0,127}`。 | 
|  `commitMessage`  | 字符串 | 否 | 初始版本的提交消息。最多 500 个字符。 | 
|  `createdBy`  | 对象 | 否 | 创建此版本的来源。包含`name`（必填）和`arn`（可选）。 | 
|  `clientToken`  | 字符串 | 否 | 等效性标记。如果您使用相同的令牌重试，则该服务会返回现有捆绑包，而不是创建新的捆绑包。 | 
|  `tags`  | Map | 否 | 资源标签。最多 50 个标签。 | 

## 响应
<a name="create-bundle-response"></a>


| 字段 | Type | 说明 | 
| --- | --- | --- | 
|  `bundleArn`  | 字符串 | 创建的配置包的 ARN。 | 
|  `bundleId`  | 字符串 | 捆绑包的唯一标识符。格式：`{name}-{10-char-suffix}`。 | 
|  `versionId`  | 字符串 | 使用捆绑包创建的初始版本的 UUID。 | 
|  `createdAt`  | Timestamp | 创建捆绑包的时间。 | 

## 错误
<a name="create-bundle-errors"></a>


| 错误 | HTTP 状态 | 说明 | 
| --- | --- | --- | 
|  `ValidationException`  | 400 | 请求参数无效。检查字段限制和命名模式。 | 
|  `ConflictException`  | 409 | 具有相同名称或客户端令牌的捆绑包已经存在。 | 
|  `ServiceQuotaExceededException`  | 402 | 您已达到账户配置包的最大数量。 | 
|  `AccessDeniedException`  | 403 | 权限不足。验证 IAM 策略是否包含`bedrock-agentcore:CreateConfigurationBundle`。 | 
|  `ThrottlingException`  | 429 | 超出请求速率。使用指数回退进行重试。 | 
|  `InternalServerException`  | 500 | Service-side 错误。重试请求。 | 