在 Image YAML Builder 中为自定义组件创建组件文档 - EC2Image Builder

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

在 Image YAML Builder 中为自定义组件创建组件文档

要构建组件,必须提供YAML或JSON应用程序组件文档。该文档包含在您为自定义图像而定义的各个阶段和步骤中运行的代码。

本节中的示例创建了一个生成组件,该组件在 AWSTOE 组件管理应用程序中调用UpdateOS操作模块。该模块更新操作系统。有关 UpdateOS 操作模块的更多信息,请参阅 UpdateOS。有关 AWSTOE 应用程序组件文档的阶段、步骤和语法的更多信息,请参阅在中使用文档 AWSTOE

注意

Image Builder 根据组件文档中定义的阶段来确定组件类型,如下所示:

  • 构建 - 这是默认的组件类型。任何未归类为测试组件的组件都是构建组件。这种类型的组件在镜像构建阶段运行。如果此构建组件已定义 test 阶段,则该阶段在测试阶段运行。

  • 测试 - 要获得测试组件资格,组件文档必须仅包含一个名为 test 的阶段。对于与构建组件配置相关的测试,我们建议您不要使用独立的测试组件。相反,在关联的构建组件中使用 test 阶段。

有关 Image Builder 如何在其构建过程中使用阶段 (stage) 和时段 (phase) 来管理组件工作流的更多信息,请参阅 使用组件自定义 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