

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

# Image Builder 如何使用 AWS 任務協調器和執行器 應用程式來管理元件
<a name="toe-component-manager"></a>

EC2 Image Builder 使用 AWS 任務協調器和執行器 (AWS TOE) 應用程式來協調複雜的工作流程、修改系統組態，以及測試您的映像，而不需要額外的 devops 指令碼或程式碼。此應用程式會管理和執行實作其宣告文件結構描述的元件。

AWS TOE 是獨立應用程式，Image Builder 會在您建立映像時在其建置和測試執行個體上安裝。您也可以在 EC2 執行個體上手動安裝它，以建立您自己的自訂元件。它不需要任何額外的設定，也可以在內部部署上執行。

**Topics**
+ [AWS TOE 下載](#toe-downloads)
+ [支援地區](#toe-supported-regions)
+ [AWS TOE 命令參考](#toe-commands)
+ [手動設定以使用 開發自訂元件 AWS TOE](toe-get-started.md)
+ [使用自訂 AWS TOE 元件的元件文件架構](toe-use-documents.md)
+ [AWS TOE 元件管理員支援的動作模組](toe-action-modules.md)
+ [設定 AWS TOE 執行命令的輸入](toe-run-config-input.md)

## AWS TOE 下載
<a name="toe-downloads"></a>

若要安裝 AWS TOE，請選擇架構和平台的下載連結。如果您連接到服務的 VPC 端點 （例如映像建置器），則必須連接自訂端點政策，其中包含 S3 儲存貯體的 AWS TOE 下載存取權。否則，您的建置和測試執行個體將無法下載引導指令碼 (`bootstrap.sh`) 並安裝 AWS TOE 應用程式。如需更多資訊，請參閱[為映像建置器建立 VPC 端點政策](vpc-interface-endpoints.md#vpc-endpoint-policy)。

**重要**  
AWS 正在暫停對 TLS 版本 1.0 和 1.1 的支援。若要存取 S3 儲存貯體進行 AWS TOE 下載，您的用戶端軟體必須使用 TLS 1.2 版或更新版本。如需詳細資訊，請參閱此[AWS 安全部落格文章](https://aws.amazon.com/blogs/security/tls-1-2-required-for-aws-endpoints/)。


| 架構 | 平台 | 下載連結 | 範例 | 
| --- | --- | --- | --- | 
| 386 | AL 2 和 2023<br />RHEL 7、8 和 9<br />Ubuntu 16.04、18.04、20.04、22.04 和 24.04<br />CentOS 7 和 8<br />SUSE 12 和 15 | `https://awstoe-<region>.s3.<region>.amazonaws.com/latest/linux/386/awstoe` | [https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/linux/386/awstoe](https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/linux/386/awstoe) | 
| AMD64 | AL 2 和 2023<br />RHEL 7、8 和 9<br />Ubuntu 16.04、18.04、20.04、22.04 和 24.04<br />CentOS 7 和 8<br />CentOS Stream 8<br />SUSE 12 和 15 | https://awstoe-<region>.s3.<region>.amazonaws.com/latest/linux/amd64/awstoe | [https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/linux/amd64/awstoe](https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/linux/amd64/awstoe) | 
| AMD64 | macOS 10.14.x (Mojave)、10.15.x (Catalina)、11.x (Big Sur)、12.x (Monterey) | https://awstoe-{{region}}.s3.{{region}}.amazonaws.com/latest/darwin/amd64/awstoe | [https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/darwin/amd64/awstoe](https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/darwin/amd64/awstoe) | 
| AMD64 | Windows Server 2012 R2、2016、2019 和 2022 |  `https://awstoe-<region>.s3.<region>.amazonaws.com/latest/windows/amd64/awstoe.exe` | [https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/windows/amd64/awstoe.exe](https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/windows/amd64/awstoe.exe) | 
| ARM64 | AL 2 和 2023<br />RHEL 7、8 和 9<br />Ubuntu 16.04、18.04、20.04、22.04 和 24.04<br />CentOS 7 和 8<br />CentOS Stream 8<br />SUSE 12 和 15 | https://awstoe-<region>.s3.<region>.amazonaws.com/latest/linux/arm64/awstoe | [https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/linux/arm64/awstoe](https://awstoe-us-east-1.s3.us-east-1.amazonaws.com/latest/linux/arm64/awstoe) | 

## 支援地區
<a name="toe-supported-regions"></a>

AWS TOE 在下列 區域中支援 做為獨立應用程式。


| AWS 區域 名稱 | AWS 區域 | 
| --- | --- | 
| 美國東部 (俄亥俄) | us-east-2 | 
| 美國東部 (維吉尼亞北部) | us-east-1 | 
| AWS GovCloud （美國東部） | us-gov-east-1 | 
| AWS GovCloud （美國西部） | us-gov-west-1 | 
| 美國西部 (加利佛尼亞北部) | us-west-1 | 
| 美國西部 (奧勒岡) | us-west-2 | 
| Africa (Cape Town) | af-south-1 | 
| 亞太區域 (香港) | ap-east-1 | 
| 亞太區域 (大阪) | ap-northeast-3 | 
| 亞太區域 (首爾) | ap-northeast-2 | 
| 亞太區域 (孟買) | ap-south-1 | 
| 亞太區域 (海德拉巴) | ap-south-2 | 
| 亞太區域 (新加坡) | ap-southeast-1 | 
| 亞太區域 (雪梨) | ap-southeast-2 | 
| 亞太區域 (雅加達) | ap-southeast-3 | 
| 亞太區域 (東京) | ap-northeast-1 | 
| 加拿大 (中部) | ca-central-1 | 
| 歐洲 (法蘭克福) | eu-central-1 | 
| 歐洲 (蘇黎世) | eu-central-2 | 
| Europe (Stockholm) | eu-north-1 | 
| 歐洲 (米蘭) | eu-south-1 | 
| 歐洲 (西班牙) | eu-south-2 | 
| 歐洲 (愛爾蘭) | eu-west-1 | 
| 歐洲 (倫敦) | eu-west-2 | 
| 歐洲 (巴黎) | eu-west-3 | 
| 以色列 (特拉維夫) | il-central-1 | 
| 中東 (阿拉伯聯合大公國) | me-central-1 | 
| Middle East (Bahrain) | me-south-1 | 
| 南美洲 (聖保羅) | sa-east-1 | 
| 中國 (北京) | cn-north-1 | 
| 中國 (寧夏) | cn-northwest-1 | 

## AWS TOE 命令參考
<a name="toe-commands"></a>

AWS TOE 是在 Amazon EC2 執行個體上執行的命令列元件管理應用程式。當 Image Builder 啟動 EC2 組建或測試執行個體時，它會在執行個體 AWS TOE 上安裝 。然後，它會在 中執行 AWS TOE 命令 AWS CLI ，以安裝或驗證映像或容器配方中指定的元件。

**注意**  
有些 AWS TOE 動作模組需要更高的許可，才能在 Linux 伺服器上執行。若要使用提升的許可，請在命令語法前面加上 **sudo**，或在執行下列連結的**sudo su**命令之前，在您登入時執行一次命令。如需 AWS TOE 動作模組的詳細資訊，請參閱 [AWS TOE 元件管理員支援的動作模組](toe-action-modules.md)。

***[run](#cmd-run)***  
使用 **run**命令來執行一或多個元件文件的 YAML 文件指令碼。

***[validate](#cmd-validate)***  
執行 **validate**命令來驗證一或多個元件文件的 YAML 文件語法。

### awstoe run 命令
<a name="cmd-run"></a>

此命令執行 YAML 元件文件指令碼的順序，會包含在 `--config` 參數指定的組態檔案中，或 `--documents` 參數指定的元件文件清單。

**注意**  
您必須明確指定下列其中一個參數，絕不能同時指定兩者：  
--config  
-- 文件

#### 語法
<a name="run-syntax"></a>

```
awstoe run [--config <file path>] [--cw-ignore-failures <?>] 
      [--cw-log-group <?>] [--cw-log-region {{us-west-2}}] [--cw-log-stream <?>] 
      [--document-s3-bucket-owner <owner>] [--documents <file path,file path,...>] 
      [--execution-id <?>] [--log-directory <file path>] 
      [--log-s3-bucket-name <name>] [--log-s3-bucket-owner <owner>] 
      [--log-s3-key-prefix <?>] [--parameters {{name1}}={{value1}},{{name2}}={{value2}}...] 
      [--phases <phase name>] [--state-directory <directory path>] [--version <?>] 
      [--help] [--trace]
```

#### 參數和選項
<a name="run-parameters"></a>參數

**--config {{`./config-example.json`}}**  
簡短格式：-c {{`./config-example.json`}}  
組態檔案 *（條件式）*。此參數包含 JSON 檔案的檔案位置，其中包含此命令正在執行之元件的組態設定。如果您在組態檔案中指定**run**命令設定，則不得指定 `--documents` 參數。如需輸入組態的詳細資訊，請參閱 [設定 AWS TOE 執行命令的輸入](toe-run-config-input.md)。  
有效位置包括：  
+ 本機檔案路徑 ({{`./config-example.json`}})
+ S3 URI (`s3://{{bucket/key}}`)

**--cw-ignore-failures**  
簡短格式：不適用  
忽略 CloudWatch Logs 中的記錄失敗。

**--cw-log-group**  
簡短格式：不適用  
CloudWatch Logs `LogGroup`的名稱。

**--cw-log-region**  
簡短格式：不適用  
套用至 CloudWatch Logs AWS 的區域。

**--cw-log-stream**  
簡短格式：不適用  
CloudWatch Logs `LogStream`的名稱，會指示檔案的串流 AWS TOE 位置`console.log`。

**--document-s3-bucket-owner**  
簡短格式：不適用  
S3 URI 型文件儲存貯體擁有者的帳戶 ID。

**--文件、 {{`./doc-1.yaml``./doc-n.yaml`}}**  
簡短格式：-d{{`./doc-1.yaml`}}、{{`./doc-n`}}  
元件文件 *（條件式）*。此參數包含以逗號分隔的檔案位置清單，以供 YAML 元件文件執行。如果您使用 `--documents` 參數為**run**命令指定 YAML 文件，則不得指定 `--config` 參數。  
有效位置包括：  
+ 本機檔案路徑 ({{./component-doc-example.yaml)。}}
+ S3 URIs(`s3://{{bucket/key}}`)。
+ Image Builder 元件建置版本 ARNs(arn：aws：imagebuilder：us-west-{{2：123456789012}}：component/{{my-example-component}}/2021.12.02/1)。
清單中的項目之間沒有空格，只有逗號。

**--execution-id**  
簡短格式：-i  
這是套用至目前**run**命令執行的唯一 ID。此 ID 包含在輸出和日誌檔案名稱中，以唯一識別這些檔案，並將其連結至目前的命令執行。如果沒有此設定， AWS TOE 會產生 GUID。

**--log-directory**  
簡短格式：-l  
 AWS TOE 儲存此命令執行中所有日誌檔案的目的地目錄。根據預設，此目錄位於下列父目錄內：`TOE_<DATETIME>_<EXECUTIONID>`。如果您未指定日誌目錄， AWS TOE 會使用目前的工作目錄 (`.`)。

**--log-s3-bucket-name**  
簡短格式：-b  
如果元件日誌存放在 Amazon S3 （建議） 中， 會將元件應用程式日誌 AWS TOE 上傳到此參數中名為 的 S3 儲存貯體。

**--log-s3-bucket-owner**  
簡短格式：不適用  
如果元件日誌存放在 Amazon S3 （建議），這是 AWS TOE 寫入日誌檔案之 儲存貯體的擁有者帳戶 ID。

**--log-s3-key-prefix**  
簡短格式：-k  
如果元件日誌存放在 Amazon S3 （建議），這是儲存貯體中日誌位置的 S3 物件金鑰字首。

**--parameters {{name1}}={{value1}}，{{name2}}={{value2}}...**  
簡短格式：不適用  
參數是元件文件中定義的可變變數，具有呼叫應用程式可在執行時間提供的設定。

**--階段**  
簡短格式：-p  
以逗號分隔的清單，指定要從 YAML 元件文件執行哪些階段。如果元件文件包含其他階段，則不會執行這些階段。

**--state-directory**  
簡短格式：-s  
存放狀態追蹤檔案的檔案路徑。

**--version**  
簡短格式：-v  
指定元件應用程式版本。選項

**--help**  
簡短格式：-h  
顯示使用元件管理應用程式選項的說明手冊。

**-- 追蹤**  
簡短格式：-t  
啟用主控台的詳細記錄。

### awstoe validate 命令
<a name="cmd-validate"></a>

當您執行此命令時，它會驗證 `--documents` 參數指定的每個元件文件的 YAML 文件語法。

#### 語法
<a name="validate-syntax"></a>

```
awstoe validate [--document-s3-bucket-owner <owner>] 
      --documents <file path,file path,...> [--help] [--trace]
```

#### 參數和選項
<a name="validate-parameters"></a>參數

**--document-s3-bucket-owner**  
簡短格式：不適用  
提供的 S3 URI 型文件的來源帳戶 ID。

**--文件 {{`./doc-1.yaml`、`./doc-n.yaml`}}**  
簡短格式：-d{{`./doc-1.yaml`}}、{{`./doc-n`}}  
元件文件 *（必要）*。此參數包含以逗號分隔的檔案位置清單，以供 YAML 元件文件執行。有效位置包括：  
+ 本機檔案路徑 ({{./component-doc-example.yaml}})
+ S3 URIs(`s3://{{bucket/key}}`)
+ 映像建置器元件建置版本 ARNs(arn：aws：imagebuilder：us-west-{{2：123456789012}}：component/{{my-example-component}}/2021.12.02/1)
清單中的項目之間沒有空格，只有逗號。選項

**--help**  
簡短格式：-h  
顯示使用元件管理應用程式選項的說明手冊。

**-- 追蹤**  
簡短格式：-t  
啟用主控台的詳細記錄。