

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 Amazon Bedrock 資料自動化 CLI
<a name="bda-cli-guide"></a>

 Amazon Bedrock 資料自動化 (BDA) 功能提供簡化的 CLI 工作流程來處理您的資料。對於所有模態，此工作流程包含三個主要步驟：建立專案、建立自訂輸出的藍圖，以及處理文件。本指南會逐步引導您使用 BDA 的金鑰 CLI 命令。

## 建立您的第一個 Data Automation 專案
<a name="create-data-automation-project-cli"></a>

若要開始使用 BDA，請先使用 `create-data-automation-project` 命令建立專案。

請參考我們將要處理的此護照範例：

![\[alt text not found\]](http://docs.aws.amazon.com/zh_tw/bedrock/latest/userguide/images/bda/passport2.png)


建立專案時，您必須為要處理的檔案類型定義組態設定。下列命令代表建立影像處理專案的最小工作範例：

```
aws bedrock-data-automation create-data-automation-project \
    --project-name "ImageProcessingProject" \
    --standard-output-configuration '{
        "image": {
            "extraction": {
                "category": {
                    "state": "ENABLED",
                    "types": ["TEXT_DETECTION"]
                },
                "boundingBox": {
                    "state": "ENABLED"
                }
            },
            "generativeField": {
                "state": "ENABLED"
            }
        }
    }'
```

命令會驗證輸入組態，並使用唯一的 ARN 建立新的專案。回應將包含專案 ARN 和階段：

```
{
    "projectArn": "Amazon Resource Name (ARN)",
    "projectStage": "DEVELOPMENT",
    "status": "IN_PROGRESS"
}
```

如果專案建立時未使用參數，則將套用預設設定。例如，處理影像時，預設會啟用影像摘要和文字偵測。

## 完成參數參考
<a name="create-project-parameters"></a>

下表顯示 `create-data-automation-project` 命令的所有可用參數：


**create-data-automation-project 的參數**  

| 參數 | 必要 | 預設 | Description | 
| --- | --- | --- | --- | 
| --project-name | 是 | N/A | Data Automation 專案的名稱 | 
| --project-type | 否 | 專案的類型會定義可與哪些執行時間處理 API 搭配使用。 ASYNC專案只能與 invoke-bedrock-data-automation-async API 搭配使用，而SYNC專案只能與 invoke-bedrock-data-automation API 搭配使用。 | 
| --project-stage | 否 | LIVE | 專案的階段 (DEVELOPMENT 或 LIVE) | 
| --standard-output-configuration | 是 | N/A | 標準輸出處理的 JSON 組態 | 
| --custom-output-configuration | 否 | N/A | 自訂輸出處理的 JSON 組態 | 
| --encryption-configuration | 否 | N/A | 專案的加密設定 | 
| --client-token | 否 | 自動產生 | 請求冪等性的唯一識別符 | 

## 建立藍圖
<a name="create-blueprint-cli"></a>

建立專案之後，您可以使用 `create-blueprint` 命令建立藍圖來定義資料處理的結構。

以下是建立專為處理護照量身打造的藍圖的最小工作範例：

```
aws bedrock-data-automation create-blueprint \
    --blueprint-name "passport-blueprint" \
    --type "IMAGE" \
    --blueprint-stage "DEVELOPMENT" \
    --schema '{
        "class": "Passport",
        "description": "Blueprint for processing passport images",
        "properties": {
            "passport_number": {
                "type": "string",
                "inferenceType": "explicit",
                "instruction": "The passport identification number"
            },
            "full_name": {
                "type": "string",
                "inferenceType": "explicit",
                "instruction": "The full name of the passport holder"
            }
        }
    }'
```

命令會使用指定的結構描述來建立新的藍圖。然後，您可以在處理文件時使用此藍圖，根據您定義的結構描述擷取結構化資料。

## 使用您的藍圖
<a name="using-blueprint-cli"></a>

### 將藍圖新增至專案
<a name="adding-blueprint-to-project"></a>

若要將藍圖新增至您的專案，請使用 `update-data-automation-project` 命令：

```
aws bedrock-data-automation update-data-automation-project \
    --project-arn "Amazon Resource Name (ARN)" \
    --standard-output-configuration '{
        "image": {
            "extraction": {
                "category": {
                    "state": "ENABLED",
                    "types": ["TEXT_DETECTION"]
                },
                "boundingBox": {
                    "state": "ENABLED"
                }
            },
            "generativeField": {
                "state": "ENABLED",
                "types": ["IMAGE_SUMMARY"]
            }
        }
    }' \
    --custom-output-configuration '{
        "blueprints": [
            {
                "blueprintArn": "Amazon Resource Name (ARN)",
                "blueprintVersion": "1",
                "blueprintStage": "LIVE"
            }
        ]
    }'
```

### 驗證藍圖整合
<a name="verifying-blueprint-integration"></a>

您可以使用 `get-data-automation-project` 命令來驗證藍圖整合：

```
aws bedrock-data-automation get-data-automation-project \
    --project-arn "Amazon Resource Name (ARN)"
```

### 管理多個藍圖
<a name="managing-multiple-blueprints"></a>

使用 `list-blueprints` 命令來檢視您的所有藍圖：

```
aws bedrock-data-automation list-blueprints
```

## 非同步處理文件
<a name="invoke-data-automation-cli"></a>

使用 BDA 處理文件之前，您必須先將文件上傳至 S3 儲存貯體。設定專案後，您可以使用 `invoke-data-automation-async`命令處理文件：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
    --input-configuration '{
        "s3Uri": "s3://my-bda-documents/invoices/invoice-123.pdf"
    }' \
    --output-configuration '{
        "s3Uri": "s3://my-bda-documents/output/"
    }' \
    --data-automation-configuration '{
        "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
        "stage": "LIVE"
    }' \
    --data-automation-profile-arn "Amazon Resource Name (ARN)"
```

命令會傳回調用 ARN，您可以用來檢查處理狀態：

```
{
    "invocationArn": "Amazon Resource Name (ARN)"
}
```

## 檢查處理狀態
<a name="get-data-automation-status-cli"></a>

若要檢查處理任務的狀態，請使用 `get-data-automation-status` 命令：

```
aws bedrock-data-automation-runtime get-data-automation-status \
    --invocation-arn "Amazon Resource Name (ARN)"
```

命令會傳回處理任務的目前狀態：

```
{
    "status": "COMPLETED",
    "creationTime": "2025-07-09T12:34:56.789Z",
    "lastModifiedTime": "2025-07-09T12:45:12.345Z",
    "outputLocation": "s3://my-bda-documents/output/efgh5678/"
}
```

可能的狀態值包括：
+ `IN_PROGRESS`：處理任務目前正在執行中。
+ `COMPLETED`：處理任務已成功完成。
+ `FAILED`：處理任務失敗。檢查回應以取得錯誤詳細資訊。
+ `STOPPED`：處理任務已手動停止。

## 擷取結果
<a name="retrieve-results-cli"></a>

處理完成後，您可以列出 S3 儲存貯體中的輸出檔案：

```
aws s3 ls s3://my-bda-documents/output/efgh5678/
```

下載結果到您的本機電腦：

```
aws s3 cp s3://my-bda-documents/output/efgh5678/ ~/Downloads/bda-results/ --recursive
```

輸出包含根據您的專案組態的結構化資料，以及您套用的任何藍圖。

## 同步處理文件
<a name="process-docs-sync"></a>

使用 BDA 處理文件之前，您必須先將文件上傳至 S3 儲存貯體。同步 API 透過 S3 儲存貯體或影像位元組 （即在沒有 S3 的情況下處理文件） 來同步 API。命令會根據您的專案組態和您已套用的任何藍圖傳回結構化資料：

```
aws bedrock-data-automation-runtime invoke-data-automation \
    --input-configuration '{
        "s3Uri": "s3://my-bda-documents/invoices/invoice-123.pdf"
    }' \
    --data-automation-configuration '{
        "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
        "stage": "LIVE"
    }' \
    --data-automation-profile-arn "Amazon Resource Name (ARN)"
```

## 同步處理映像
<a name="process-images-sync"></a>

命令會根據您的專案組態和您已套用的任何藍圖傳回結構化資料：

```
aws bedrock-data-automation-runtime invoke-data-automation \
    --input-configuration '{
        "s3Uri": "s3://my-bda-documents/invoices/advertisement_latest.jpeg"
    }' \
    --data-automation-configuration '{
        "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
        "stage": "LIVE"
    }' \
    --data-automation-profile-arn "Amazon Resource Name (ARN)"
```

# 藍圖操作 CLI
<a name="bda-blueprint-operations"></a>

本指南涵蓋透過 AWS Command Line Interface (CLI) for Amazon BedrockData Automation (BDA) 提供的藍圖操作。

## 建立藍圖
<a name="create-blueprints-cli"></a>

藍圖定義您要從文件、影像、音訊或影片檔案擷取之資料的結構和屬性。使用 create-blueprint 命令來定義新的藍圖。

下列命令會建立量身打造的新藍圖，以從護照影像擷取資料。

**語法**

```
aws bedrock-data-automation create-blueprint \
      --blueprint-name "passport-blueprint" \
      --type "IMAGE" \
      --blueprint-stage "DEVELOPMENT" \
      --schema '{
        "class": "Passport",
        "description": "Blueprint for processing passport images",
        "properties": {
          "passport_number": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The passport identification number"
          },
          "full_name": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The full name of the passport holder"
          },
          "expiration_date": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The passport expiration date"
          }
        }
      }'
```

## 完成參數參考
<a name="create-blueprint-parameters"></a>

下表顯示 `create-blueprint` 命令的所有可用參數：


**create-blueprint 的參數**  

| 參數 | 必要 | 預設 | Description | 
| --- | --- | --- | --- | 
| --blueprint-name | 是 | N/A | 藍圖的名稱 | 
| --type | 是 | N/A | 內容類型 (IMAGE、DOCUMENT、AUDIO、VIDEO) | 
| --blueprint-stage | 否 | LIVE | 藍圖階段 (DEVELOPMENT 或 LIVE) | 
| --schema | 是 | N/A | 定義藍圖結構的 JSON 結構描述 | 
| --client-token | 否 | 自動產生 | 請求冪等性的唯一識別符 | 

## 檢視藍圖組態
<a name="view-blueprint-cli"></a>

**列出所有藍圖**

使用 list-blueprints 命令來擷取與您的帳戶相關聯的所有藍圖清單。

**語法**

```
aws bedrock-data-automation list-blueprints
```

**檢視藍圖詳細資訊**

若要查看特定藍圖的詳細資訊，包括其結構描述和組態，請使用 get-blueprint 命令。

**語法**

```
aws bedrock-data-automation get-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)"
```

**檢查特定版本**

使用版本控制的藍圖時，請使用 get-blueprint 命令搭配 --blueprint-version 選項來檢視特定版本。

**語法**

```
      aws bedrock-data-automation get-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)" \
      --blueprint-version "version-number"
```

**檢查特定階段**

若要檢視 DEVELOPMENT 或 LIVE 階段的藍圖，請使用：

```
      aws bedrock-data-automation get-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)" \
      --blueprint-stage "LIVE"
```

## 編輯藍圖規格
<a name="edit-blueprint-cli"></a>

**更新藍圖設定**

若要修改現有藍圖的結構描述或屬性，請使用 update-blueprint 命令。

**語法**

```
aws bedrock-data-automation update-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)" \
      --schema '{
        "class": "Passport",
        "description": "Updated blueprint for processing passport images",
        "properties": {
          "passport_number": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The passport identification number"
          },
          "full_name": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The full name of the passport holder"
          },
          "expiration_date": {
            "type": "string",
            "inferenceType": "explicit",
            "instruction": "The passport expiration date"
          }
        }
      }'
```

**注意：**更新藍圖時，您必須提供完整的結構描述，即使您未變更的欄位也是如此。

**提升為 LIVE**

若要將藍圖從 DEVELOPMENT 移至 LIVE 階段進行生產，請使用 update-blueprint 命令搭配 --blueprint-stage 選項。

**語法**

```
aws bedrock-data-automation update-blueprint \
      --blueprint-arn "Amazon Resource Name (ARN)" \
      --blueprint-stage "LIVE"
```

**藍圖版本控制**

使用 create-blueprint-version 指令建立藍圖的新版本，以便在進行重大變更之前保留其目前狀態。

**語法**

```
aws bedrock-data-automation create-blueprint-version \
      --blueprint-arn "Amazon Resource Name (ARN)"
```

## 管理藍圖標籤
<a name="tag-management-cli"></a>

標籤可協助使用者組織和分類藍圖，以簡化管理。

**新增標籤**

新增標籤，將中繼資料套用至您的藍圖。

**語法**

```
aws bedrock-data-automation tag-resource \
      --resource-arn "Amazon Resource Name (ARN)" \
      --tags '{"Department":"Finance","Project":"PassportProcessing"}'
```

**移除標籤**

使用 untag-resource 命令從藍圖中移除特定標籤。

**語法**

```
aws bedrock-data-automation untag-resource \
      --resource-arn "Amazon Resource Name (ARN)" \
      --tag-keys '["Department","Project"]'
```

**檢視標籤**

使用 list-tags-for-resource 命令列出與藍圖相關聯的所有標籤。

**語法**

```
aws bedrock-data-automation list-tags-for-resource \
      --resource-arn "Amazon Resource Name (ARN)"
```

## 刪除藍圖
<a name="delete-blueprint-cli"></a>

**刪除整個藍圖**

使用 delete-blueprint 命令永久移除藍圖及其所有版本。

**語法**

```
aws bedrock-data-automation delete-blueprint \
          --blueprint-arn "Amazon Resource Name (ARN)"
```

**注意：**此命令會永久刪除藍圖，且無法復原。

**重要：**您無法刪除任何專案目前正在使用的藍圖。刪除前，請先確定任何專案的自訂輸出組態中未參考該藍圖。

## 藍圖最佳化
<a name="blueprint-optimization-cli"></a>

### 調用藍圖最佳化
<a name="invoking-blueprint-optimization"></a>

啟動非同步藍圖最佳化任務，以改善每個藍圖欄位的藍圖說明和結果準確性。

**語法**

```
aws bedrock-data-automation invoke-blueprint-optimization-async \
    --blueprint blueprintArn="arn:aws:bedrock:<region>:<account_id>:blueprint/<blueprint_id>",stage="DEVELOPMENT" \
    --samples '[
        {
            "assetS3Object": {
                "s3Uri": "s3://my-optimization-bucket/samples/document1.pdf"
            },
            "groundTruthS3Object": {
                "s3Uri": "s3://my-optimization-bucket/ground-truth/document1-expected.json"
            }
        }
    ]' \
    --output-configuration s3Object='{s3Uri="s3://my-optimization-bucket/results/optimization-output"}' \
    --data-automation-profile-arn "Amazon Resource Name (ARN):data-automation-profile/default"
```

### 檢查藍圖最佳化狀態
<a name="checking-blueprint-optimization-status"></a>

監控藍圖最佳化任務的進度和結果。

**語法**

```
aws bedrock-data-automation get-blueprint-optimization-status \
    --invocation-arn "arn:aws:bedrock:<region>:<account_id>:blueprint-optimization-invocation/opt-12345abcdef"
```

使用此命令來追蹤最佳化任務狀態。回應包含目前狀態 （建立、InProgress、成功、ServiceError 或 ClientError)，以及完成時的輸出組態詳細資訊。

### 複製藍圖階段
<a name="copying-blueprint-stages"></a>

將藍圖從一個階段複製到另一個階段

**語法**

```
aws bedrock-data-automation copy-blueprint-stage \
    --blueprint-arn "arn:aws:bedrock:<region>:<account_id>:blueprint/<blueprint_id>" \
    --source-stage "DEVELOPMENT" \
    --target-stage "LIVE"
```

**注意：**此命令會將整個藍圖組態從來源階段複製到目標階段，覆寫目標階段中的任何現有組態。

**重要：**確保藍圖在複製到生產 (LIVE) 階段之前，已在來源階段經過徹底測試。此操作難以復原。

# 透過 CLI 處理
<a name="bda-document-processing-cli"></a>

使用 BDA 處理文件之前，您必須先將文件上傳至 S3 儲存貯體：

**語法**

```
aws s3 cp <source> <target> [--options]
```

範例：

```
aws s3 cp /local/path/document.pdf s3://my-bda-bucket/input/document.pdf
```

------
#### [ Async ]

**基本處理命令結構**

使用 `invoke-data-automation-async` 命令來處理檔案：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
        --input-configuration '{
            "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg"
        }' \
        --output-configuration '{
            "s3Uri": "s3://amzn-s3-demo-bucket/output/"
        }' \
        --data-automation-configuration '{
            "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
            "stage": "LIVE"
        }' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
```

**進階處理命令結構**

**依照時間段處理影片**

對於影片檔案，您可以指定要處理的時間段：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
        --input-configuration '{
            "s3Uri": "s3://my-bucket/video.mp4",
            "assetProcessingConfiguration": {
                "video": {
                    "segmentConfiguration": {
                        "timestampSegment": {
                            "startTimeMillis": 0,
                            "endTimeMillis": 300000
                        }
                    }
                }
            }
        }' \
        --output-configuration '{
            "s3Uri": "s3://my-bucket/output/"
        }' \
        --data-automation-configuration '{
            "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
            "stage": "LIVE"
        }' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
```

**使用自訂藍圖**

您可以直接在命令中指定自訂藍圖：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
        --input-configuration '{
            "s3Uri": "s3://my-bucket/document.pdf"
        }' \
        --output-configuration '{
            "s3Uri": "s3://my-bucket/output/"
        }' \
        --blueprints '[
            {
                "blueprintArn": "Amazon Resource Name (ARN)",
                "version": "1",
                "stage": "LIVE"
            }
        ]' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
```

**新增加密組態**

為了增強安全性，您可以新增加密組態：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
        --input-configuration '{
            "s3Uri": "s3://my-bucket/document.pdf"
        }' \
        --output-configuration '{
            "s3Uri": "s3://my-bucket/output/"
        }' \
        --data-automation-configuration '{
            "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
            "stage": "LIVE"
        }' \
        --encryption-configuration '{
            "kmsKeyId": "Amazon Resource Name (ARN)",
            "kmsEncryptionContext": {
                "Department": "Finance",
                "Project": "DocumentProcessing"
            }
        }' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
```

**事件通知**

啟用 EventBridge 通知以完成處理：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
        --input-configuration '{
            "s3Uri": "s3://my-bucket/document.pdf"
        }' \
        --output-configuration '{
            "s3Uri": "s3://my-bucket/output/"
        }' \
        --data-automation-configuration '{
            "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
            "stage": "LIVE"
        }' \
        --notification-configuration '{
            "eventBridgeConfiguration": {
                "eventBridgeEnabled": true
            }
        }' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
```

**檢查處理狀態**

使用 `get-data-automation-status` 命令來檢查處理任務的狀態：

```
aws bedrock-data-automation-runtime get-data-automation-status \
        --invocation-arn "Amazon Resource Name (ARN)"
```

回應將包含目前狀態：

```
{
        "status": "COMPLETED",
        "creationTime": "2025-07-24T12:34:56.789Z",
        "lastModifiedTime": "2025-07-24T12:45:12.345Z",
        "outputLocation": "s3://my-bucket/output/abcd1234/"
        }
```

**擷取處理結果**

**在 S3 中尋找輸出檔案**

列出 S3 儲存貯體中的輸出檔案：

```
aws s3 ls s3://amzn-s3-demo-bucket/output/
```

下載結果到您的本機電腦：

```
aws s3 cp s3://amzn-s3-demo-bucket/output/ ~/Downloads/bda-results/ --recursive
```

**了解輸出結構**

輸出通常包括：
+ `standard-output.json`：包含標準擷取結果
+ `custom-output.json`：包含自訂藍圖的結果
+ `metadata.json`：包含處理中繼資料和可信度分數

**常見回應欄位**

標準輸出通常包括：
+ `extractedData`：主要擷取的資訊
+ `confidence`：每個擷取欄位的可信度分數
+ `metadata`：處理資訊，包括時間戳記和模型詳細資訊
+ `boundingBoxes`：偵測到元素的位置資訊 (如果已啟用)

**錯誤處理和疑難排解**

常見的錯誤案例和解決方案：
+ **無效的 S3 URI**：確保您的 S3 儲存貯體存在且您具有適當的許可
+ **缺少 data-automation-profile-arn**：所有處理請求都需要此參數
+ **找不到專案**：確認您的專案 ARN 正確且專案存在
+ **不支援的檔案格式**：檢查 BDA 是否支援您的檔案格式

**將標籤新增至處理任務**

您可以新增標籤，以協助組織和追蹤處理任務：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
        --input-configuration '{
            "s3Uri": "s3://my-bucket/document.pdf"
        }' \
        --output-configuration '{
            "s3Uri": "s3://my-bucket/output/"
        }' \
        --data-automation-configuration '{
            "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
            "stage": "LIVE"
        }' \
        --tags '[
            {
                "key": "Department",
                "value": "Finance"
            },
            {
                "key": "Project",
                "value": "InvoiceProcessing"
            }
        ]' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
```

------
#### [ Sync ]

**基本處理命令結構**

使用 `invoke-data-automation` 命令來處理檔案：

```
        aws bedrock-data-automation-runtime invoke-data-automation \
        --input-configuration '{
            "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg"
        }' \
        --data-automation-configuration '{
            "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
            "stage": "LIVE"
        }' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
        --region "aws-region"
```

**進階處理命令結構**

輸出至 S3 儲存貯體

```
        aws bedrock-data-automation-runtime invoke-data-automation \
        --input-configuration '{
            "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg"
        }' \
        --output-configuration '{"s3Uri": "s3://amzn-s3-demo-bucket/output/" }' \
        --data-automation-configuration '{
            "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
            "stage": "LIVE"
        }' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
        --region "aws-region"   //document only
```

使用位元組輸入

```
        aws bedrock-data-automation-runtime invoke-data-automation \
        --input-configuration '{
            "bytes": #blob input
        }' \
        --output-configuration '{"s3Uri": "s3://amzn-s3-demo-bucket/output/" }' \
        --data-automation-configuration '{
            "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
            "stage": "LIVE"
        }' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
        --region "aws-region"
```

**注意**  
**位元組**  
base64 編碼文件位元組的 Blob。位元組 Blob 中提供的文件大小上限為 50 MB。類型應為 Base64-encoded的二進位資料物件。

**使用自訂藍圖 （僅適用於映像）**

```
        aws bedrock-data-automation-runtime invoke-data-automation \
        --input-configuration '{
            "s3Uri": "s3://amzn-s3-demo-bucket/sample-images/sample-image.jpg"
        }' \
        --blueprints '[{"blueprintArn": "Amazon Resource Name (ARN)", "version": "1", "stage": "LIVE" } ]' \
        --data-automation-profile-arn "Amazon Resource Name (ARN)"
        --region "aws-region"
```

------

# 處理使用案例
<a name="bda-document-processing-examples"></a>

Amazon Bedrock Data Automation 可讓您透過命令列介面 (CLI) 處理文件、影像、音訊和影片。對於每個模態，工作流程包含建立專案、調用分析，以及擷取結果。

選擇您偏好方法的索引標籤，然後遵循下列步驟：

------
#### [ Documents ]

**從 W2 擷取資料**

![\[具有標準欄位的範例 W2 表單，示範要擷取的配置和資料欄位。\]](http://docs.aws.amazon.com/zh_tw/bedrock/latest/userguide/images/bda/W2.png)


處理 W2 表單時，範例結構描述如下：

```
{
  "class": "W2TaxForm",
  "description": "Simple schema for extracting key information from W2 tax forms",
  "properties": {
    "employerName": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The employer's company name"
    },
    "employeeSSN": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The employee's Social Security Number (SSN)"
    },
    "employeeName": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The employee's full name"
    },
    "wagesAndTips": {
      "type": "number",
      "inferenceType": "explicit",
      "instruction": "Wages, tips, other compensation (Box 1)"
    },
    "federalIncomeTaxWithheld": {
      "type": "number",
      "inferenceType": "explicit",
      "instruction": "Federal income tax withheld (Box 2)"
    },
    "taxYear": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The tax year for this W2 form"
    }
  }
}
```

調用 W2 處理的命令類似如下：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
  --input-configuration '{
    "s3Uri": "s3://w2-processing-bucket-301678011486/input/W2.png"
  }' \
  --output-configuration '{
    "s3Uri": "s3://w2-processing-bucket-301678011486/output/"
  }' \
  --data-automation-configuration '{
    "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
    "stage": "LIVE"
  }' \
  --data-automation-profile-arn "Amazon Resource Name (ARN):data-automation-profile/default"
```

預期輸出的範例為：

```
{
  "documentType": "W2TaxForm",
  "extractedData": {
    "employerName": "The Big Company",
    "employeeSSN": "123-45-6789",
    "employeeName": "Jane Doe",
    "wagesAndTips": 48500.00,
    "federalIncomeTaxWithheld": 6835.00,
    "taxYear": "2014"
  },
  "confidence": {
    "employerName": 0.99,
    "employeeSSN": 0.97,
    "employeeName": 0.99,
    "wagesAndTips": 0.98,
    "federalIncomeTaxWithheld": 0.97,
    "taxYear": 0.99
  },
  "metadata": {
    "processingTimestamp": "2025-07-23T23:15:30Z",
    "documentId": "w2-12345",
    "modelId": "amazon.titan-document-v1",
    "pageCount": 1
  }
}
```

------
#### [ Images ]

**旅遊廣告範例**

![\[範例影像，示範使用者如何從廣告擷取資訊。\]](http://docs.aws.amazon.com/zh_tw/bedrock/latest/userguide/images/bda/TravelAdvertisement.jpg)


旅遊廣告的範例結構描述如下：

```
{
  "class": "TravelAdvertisement",
  "description": "Schema for extracting information from travel advertisement images",
  "properties": {
    "destination": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The name of the travel destination being advertised"
    },
    "tagline": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The main promotional text or tagline in the advertisement"
    },
    "landscapeType": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The type of landscape shown (e.g., mountains, beach, forest, etc.)"
    },
    "waterFeatures": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "Description of any water features visible in the image (ocean, lake, river, etc.)"
    },
    "dominantColors": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The dominant colors present in the image"
    },
    "advertisementType": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The type of travel advertisement (e.g., destination promotion, tour package, etc.)"
    }
  }
}
```

調用旅遊廣告處理的命令類似如下：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
  --input-configuration '{
    "s3Uri": "s3://travel-ads-bucket-301678011486/input/TravelAdvertisement.jpg"
  }' \
  --output-configuration '{
    "s3Uri": "s3://travel-ads-bucket-301678011486/output/"
  }' \
  --data-automation-configuration '{
    "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
    "stage": "LIVE"
  }' \
  --data-automation-profile-arn "Amazon Resource Name (ARN):data-automation-profile/default"
```

預期輸出的範例為：

```
{
  "documentType": "TravelAdvertisement",
  "extractedData": {
    "destination": "Kauai",
    "tagline": "Travel to KAUAI",
    "landscapeType": "Coastal mountains with steep cliffs and valleys",
    "waterFeatures": "Turquoise ocean with white surf along the coastline",
    "dominantColors": "Green, blue, turquoise, brown, white",
    "advertisementType": "Destination promotion"
  },
  "confidence": {
    "destination": 0.98,
    "tagline": 0.99,
    "landscapeType": 0.95,
    "waterFeatures": 0.97,
    "dominantColors": 0.96,
    "advertisementType": 0.92
  },
  "metadata": {
    "processingTimestamp": "2025-07-23T23:45:30Z",
    "documentId": "travel-ad-12345",
    "modelId": "amazon.titan-image-v1",
    "imageWidth": 1920,
    "imageHeight": 1080
  }
}
```

------
#### [ Audio ]

**轉錄電話語音**

電話的範例結構描述如下：

```
{
  "class": "AudioRecording",
  "description": "Schema for extracting information from AWS customer call recordings",
  "properties": {
    "callType": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The type of call (e.g., technical support, account management, consultation)"
    },
    "participants": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The number and roles of participants in the call"
    },
    "mainTopics": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The main topics or AWS services discussed during the call"
    },
    "customerIssues": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "Any customer issues or pain points mentioned during the call"
    },
    "actionItems": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "Action items or next steps agreed upon during the call"
    },
    "callDuration": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The duration of the call"
    },
    "callSummary": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "A brief summary of the entire call"
    }
  }
}
```

調用電話通話處理的命令類似如下：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
  --input-configuration '{
    "s3Uri": "s3://audio-analysis-bucket-301678011486/input/AWS_TCA-Call-Recording-2.wav"
  }' \
  --output-configuration '{
    "s3Uri": "s3://audio-analysis-bucket-301678011486/output/"
  }' \
  --data-automation-configuration '{
    "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
    "stage": "LIVE"
  }' \
  --data-automation-profile-arn "Amazon Resource Name (ARN):data-automation-profile/default"
```

預期輸出的範例為：

```
{
  "documentType": "AudioRecording",
  "extractedData": {
    "callType": "Technical consultation",
    "participants": "3 participants: AWS Solutions Architect, AWS Technical Account Manager, and Customer IT Director",
    "mainTopics": "AWS Bedrock implementation, data processing pipelines, model fine-tuning, and cost optimization",
    "customerIssues": "Integration challenges with existing ML infrastructure, concerns about latency for real-time processing, questions about data security compliance",
    "actionItems": [
      "AWS team to provide documentation on Bedrock data processing best practices",
      "Customer to share their current ML architecture diagrams",
      "Schedule follow-up meeting to review implementation plan",
      "AWS to provide cost estimation for proposed solution"
    ],
    "callDuration": "45 minutes and 23 seconds",
    "callSummary": "Technical consultation call between AWS team and customer regarding implementation of AWS Bedrock for their machine learning workloads. Discussion covered integration approaches, performance optimization, security considerations, and next steps for implementation planning."
  },
  "confidence": {
    "callType": 0.94,
    "participants": 0.89,
    "mainTopics": 0.92,
    "customerIssues": 0.87,
    "actionItems": 0.85,
    "callDuration": 0.99,
    "callSummary": 0.93
  },
  "metadata": {
    "processingTimestamp": "2025-07-24T00:30:45Z",
    "documentId": "audio-12345",
    "modelId": "amazon.titan-audio-v1",
    "audioDuration": "00:45:23",
    "audioFormat": "WAV",
    "sampleRate": "44.1 kHz"
  },
  "transcript": {
    "segments": [
      {
        "startTime": "00:00:03",
        "endTime": "00:00:10",
        "speaker": "Speaker 1",
        "text": "Hello everyone, thank you for joining today's call about implementing AWS Bedrock for your machine learning workloads."
      },
      {
        "startTime": "00:00:12",
        "endTime": "00:00:20",
        "speaker": "Speaker 2",
        "text": "Thanks for having us. We're really interested in understanding how Bedrock can help us streamline our document processing pipeline."
      },
      {
        "startTime": "00:00:22",
        "endTime": "00:00:35",
        "speaker": "Speaker 3",
        "text": "Yes, and specifically we'd like to discuss integration with our existing systems and any potential latency concerns for real-time processing requirements."
      }
      // Additional transcript segments would continue here
    ]
  }
}
```

------
#### [ Video ]

**處理影片**

影片的範例結構描述如下：

```
{
  "class": "VideoContent",
  "description": "Schema for extracting information from video content",
  "properties": {
    "title": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The title or name of the video content"
    },
    "contentType": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The type of content (e.g., tutorial, competition, documentary, advertisement)"
    },
    "mainSubject": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "The main subject or focus of the video"
    },
    "keyPersons": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "Key people appearing in the video (hosts, participants, etc.)"
    },
    "keyScenes": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "Description of important scenes or segments in the video"
    },
    "audioElements": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "Description of notable audio elements (music, narration, dialogue)"
    },
    "summary": {
      "type": "string",
      "inferenceType": "explicit",
      "instruction": "A brief summary of the video content"
    }
  }
}
```

調用視訊處理的命令類似如下：

```
aws bedrock-data-automation-runtime invoke-data-automation-async \
  --input-configuration '{
    "s3Uri": "s3://video-analysis-bucket-301678011486/input/MakingTheCut.mp4",
    "assetProcessingConfiguration": {
      "video": {
        "segmentConfiguration": {
          "timestampSegment": {
            "startTimeMillis": 0,
            "endTimeMillis": 300000
          }
        }
      }
    }
  }' \
  --output-configuration '{
    "s3Uri": "s3://video-analysis-bucket-301678011486/output/"
  }' \
  --data-automation-configuration '{
    "dataAutomationProjectArn": "Amazon Resource Name (ARN)",
    "stage": "LIVE"
  }' \
  --data-automation-profile-arn "Amazon Resource Name (ARN):data-automation-profile/default"
```

預期輸出的範例為：

```
{
  "documentType": "VideoContent",
  "extractedData": {
    "title": "Making the Cut",
    "contentType": "Fashion design competition",
    "mainSubject": "Fashion designers competing to create the best clothing designs",
    "keyPersons": "Heidi Klum, Tim Gunn, and various fashion designer contestants",
    "keyScenes": [
      "Introduction of the competition and contestants",
      "Design challenge announcement",
      "Designers working in their studios",
      "Runway presentation of designs",
      "Judges' critique and elimination decision"
    ],
    "audioElements": "Background music, host narration, contestant interviews, and design feedback discussions",
    "summary": "An episode of 'Making the Cut' fashion competition where designers compete in a challenge to create innovative designs. The episode includes the challenge announcement, design process, runway presentation, and judging."
  },
  "confidence": {
    "title": 0.99,
    "contentType": 0.95,
    "mainSubject": 0.92,
    "keyPersons": 0.88,
    "keyScenes": 0.90,
    "audioElements": 0.87,
    "summary": 0.94
  },
  "metadata": {
    "processingTimestamp": "2025-07-24T00:15:30Z",
    "documentId": "video-12345",
    "modelId": "amazon.titan-video-v1",
    "videoDuration": "00:45:23",
    "analyzedSegment": "00:00:00 - 00:05:00",
    "resolution": "1920x1080"
  },
  "transcript": {
    "segments": [
      {
        "startTime": "00:00:05",
        "endTime": "00:00:12",
        "speaker": "Heidi Klum",
        "text": "Welcome to Making the Cut, where we're searching for the next great global fashion brand."
      },
      {
        "startTime": "00:00:15",
        "endTime": "00:00:25",
        "speaker": "Tim Gunn",
        "text": "Designers, for your first challenge, you'll need to create a look that represents your brand and can be sold worldwide."
      }
      // Additional transcript segments would continue here
    ]
  }
}
```

------