本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
从中创建AMI图像管道 Amazon CLI
您可以使用包含配置详细信息的JSON文件创建AMI映像管道,作为中create-image-pipeline命令的输入 Amazon CLI。
您的管道构建新映像以合并基础映像和组件中所有待处理更新的频率取决于您所配置的 schedule
。每个 schedule
都具有以下属性:
-
scheduleExpression
— 设置管道运行的时间计划,以评估pipelineExecutionStartCondition
并确定是否应开始构建。该计划是使用 cron 表达式配置的。有关如何在 Image Builder 中设置 cron 表达式格式的更多信息,请参阅 在 Image Builder 中使用 cron 表达式。 -
pipelineExecutionStartCondition
— 确定您的管道是否应该开始构建。有效值包括:-
EXPRESSION_MATCH_ONLY
— 每次 cron 表达式与当前时间匹配时,Pipeline 都会生成一个新映像。 -
EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE
— 除非您的基础映像或组件有待处理的更改,否则您的管道不会启动新的映像构建。
-
在中运行create-image-pipeline命令时 Amazon CLI,许多配置资源都是可选的。但是,有些资源有条件性要求,具体取决于管道创建的映像类型。AMI图像管道需要以下资源:
-
图片配方 ARN
-
基础设施配置 ARN
-
创建CLI输入JSON文件
使用您常用的文件编辑工具创建包含以下密钥的JSON文件,以及对您的环境有效的值。此示例使用名为
create-image-pipeline.json
的文件:{ "name": "
MyWindows2019Pipeline
", "description": "Builds Windows 2019 Images
", "enhancedImageMetadataEnabled": true, "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012
:image-recipe/my-example-recipe
/2020.12.03", "infrastructureConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012
:infrastructure-configuration/my-example-infrastructure-configuration
", "distributionConfigurationArn": "arn:aws:imagebuilder:us-west-2:123456789012
:distribution-configuration/my-example-distribution-configuration
", "imageTestsConfiguration": { "imageTestsEnabled": true, "timeoutMinutes": 60 }, "schedule": { "scheduleExpression": "cron(0 0 * * SUN *)", "pipelineExecutionStartCondition": "EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE" }, "status": "ENABLED" }注意
-
您必须在JSON文件路径的开头添加
file://
符号。 -
该JSON文件的路径应遵循运行该命令的基本操作系统的相应约定。例如,Windows 使用反斜杠 (\) 引用目录路径,而 Linux 和 macOS 使用正斜杠 (/)。
-
-
使用您创建的文件作为输入,运行以下命令。
aws imagebuilder create-image-pipeline --cli-input-json file://create-image-pipeline.json