在 Image Builder 生器中為自訂YAML元件建立元件文件 - EC2Image Builder

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

在 Image Builder 生器中為自訂YAML元件建立元件文件

若要建立元件,您必須提供YAML或JSON應用程式元件文件。此文件包含在階段期間執行的程式碼,以及您為影像提供自訂而定義的步驟。

本節中的範例會建立呼叫UpdateOS動作模組的建置元件 AWS TOE 組件管理應用程序。該模塊更新操作系統。如需UpdateOS動作模組的詳細資訊,請參閱更新。如需有關的階段、步驟和語法的詳細資訊 AWS TOE 應用程式元件文件,請參閱在 AWS TOE.

注意

Image Builder 會根據元件文件中定義的階段來決定元件類型,如下所示:

  • 建置-這是預設的元件類型。任何未歸類為測試組件的內容都是構建組件。這種類型的組件會在映像建置階段期間執行。如果此組建元件已定義test階段,則該階段會在「測試」階段執行。

  • 測試 — 若要符合測試元件的資格,元件文件必須只包含一個名為的階段test。對於與構建組件配置相關的測試,我們建議您不要使用獨立的測試組件。相反,請在關聯的組建元件中使用test階段。

如需 Image Builder 如何在建置程序中使用階段和階段來管理元件工作流程的詳細資訊,請參閱使用組件自定義 Image Builder 映像

若要為範例YAML應用程式建立應用程式元件文件,請依照與映像作業系統相符的索引標籤上的步驟執行。

Linux
建立YAML元件檔案

使用檔案編輯工具來建立您的零組件文件。文件範例使用名為的檔案update-linux-os.yaml,內容如下:

# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 # # Permission is hereby granted, free of charge, to any person obtaining a copy of this # software and associated documentation files (the "Software"), to deal in the Software # without restriction, including without limitation the rights to use, copy, modify, # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. name: update-linux-os description: Updates Linux with the latest security updates. schemaVersion: 1 phases: - name: build steps: - name: UpdateOS action: UpdateOS # Document End
提示

使用類似此在線YAML驗證器的工具或代碼環境中的 YAML lint 擴展來驗證您的格式YAML正確。

Windows
建立YAML元件檔案

使用檔案編輯工具來建立您的零組件文件。文件範例使用名為的檔案update-windows-os.yaml,內容如下:

# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 # # Permission is hereby granted, free of charge, to any person obtaining a copy of this # software and associated documentation files (the "Software"), to deal in the Software # without restriction, including without limitation the rights to use, copy, modify, # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. name: update-windows-os description: Updates Windows with the latest security updates. schemaVersion: 1.0 phases: - name: build steps: - name: UpdateOS action: UpdateOS # Document End
提示

使用類似此在線YAML驗證器的工具或代碼環境中的 YAML lint 擴展來驗證您的格式YAML正確。