

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

# 从更新 AMI 图像管道 AWS CLI
<a name="cli-update-image-pipeline"></a>

您可以使用 JSON 文件作为 AWS CLI中的 **update-image-pipeline** 命令的输入来更新 AMI 映像管道。要配置 JSON 文件，您必须具有 Amazon 资源名称 (ARN) 才能引用以下现有资源：
+ 要更新的映像管道
+ 映像配方
+ 基础设施配置
+ 分配设置

您可以使用中的**update-image-pipeline**命令更新 AMI 映像管道， AWS 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 文件的基础。

1. 

**创建 CLI 输入 JSON 文件**

   使用您常用的文件编辑工具创建 JSON 文件，其中包含以下密钥以及对您的环境有效的值。此示例使用名为 `create-component.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 使用正斜杠 (/)。

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

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