View a markdown version of this page

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

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

从更新容器镜像管道 Amazon CLI

您可以使用 JSON 文件作为输入来更新容器镜像管道 更新镜像管道 命令在 Amazon CLI。要配置 JSON 文件,您必须具有 Amazon 资源名称 (ARN) 才能引用以下现有资源:

  • 要更新的映像管道

  • 容器配方

  • 基础设施配置

  • 分配设置(如果包含在当前管道中)

注意

如果包含分配设置资源,则在运行命令的区域(区域 1)的分配设置中指定为目标存储库的 ECR 存储库优先级将高于容器配方中指定的目标存储库。

按照以下步骤使用 Amazon CLI中的 update-image-pipeline 命令更新容器映像管道:

注意

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

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

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

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

  1. 创建 CLI 输入 JSON 文件

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

    { "imagePipelineArn": "arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/my-example-pipeline", "containerRecipeArn": "arn:aws:imagebuilder:us-west-2:123456789012:container-recipe/my-example-recipe/2020.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