View a markdown version of this page

从更新 AMI 映像管道 Amazon CLI - EC2 Image Builder
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)。

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

从更新 AMI 映像管道 Amazon CLI

您可以使用 JSON 文件作为 Amazon CLI中的 update-image-pipeline 命令的输入来更新 AMI 映像管道。要配置 JSON 文件,您必须具有 Amazon 资源名称 (ARN) 才能引用以下现有资源:

  • 要更新的映像管道

  • 映像配方

  • 基础设施配置

  • 分配设置

您可以使用更新 AMI 映像管道 update-image-pipeline 命令在 Amazon CLI 如下所示:

注意

这个 update-image-pipeline 命令取代了整个管道配置。必须在更新请求中指定所有必需的属性。包括所有属性,包括要更改的属性和应保持不变的属性。您省略的属性将重置为默认值或被删除。

为防止意外删除现有设置,请使用 get-image-pipeline 命令检索当前配置。然后只修改要更改的字段:

aws imagebuilder get-image-pipeline --image-pipeline-arn arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/my-pipeline

使用输出作为更新请求 JSON 文件的基础。

更新请求采用相同的图像扫描配置 (imageScanningConfiguration) 作为创建请求,包括扫描类型 (imageScanningTypes) 和扫描结果条件 (scanResultCondition)。由于更新取代了整个配置,因此包括 imageScanningConfiguration 在每次对扫描其图像的管道的更新请求中。有关扫描字段,请参见 使用 Image Builder 创建自定义映像。有关扫描配置的示例,请参见 从创建 AMI 映像管道 Amazon CLI。

  1. 创建 CLI 输入 JSON 文件

    使用您常用的文件编辑工具创建 JSON 文件,其中包含以下密钥以及对您的环境有效的值。此示例使用名为 update-image-pipeline.json 的文件:

    { "imagePipelineArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/my-example-pipeline", "imageRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/my-example-recipe/2019.12.08", "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": 120 }, "schedule": { "scheduleExpression": "cron(0 0 * * MON *)", "pipelineExecutionStartCondition": "EXPRESSION_MATCH_AND_DEPENDENCY_UPDATES_AVAILABLE" }, "status": "DISABLED" }
    注意
    • JSON 文件路径开头必须包含 file:// 符号。

    • JSON 文件的路径应遵循运行命令的基本操作系统的相应约定。例如,Windows 使用反斜杠 (\) 引用目录路径,而 Linux 和 macOS 使用正斜杠 (/)。

  2. 使用创建的文件作为输入,运行以下命令。

    aws imagebuilder update-image-pipeline --cli-input-json file://update-image-pipeline.json