View a markdown version of this page

從 更新 AMI 映像管道 AWS CLI - EC2 Image Builder

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

從 更新 AMI 映像管道 AWS CLI

您可以使用 JSON 檔案來更新 AMI 映像管道,做為 中update-image-pipeline命令的輸入 AWS CLI。若要設定 JSON 檔案,您必須擁有 Amazon Resource Name (ARNs),才能參考下列現有資源:

  • 要更新的影像管道

  • 映像配方

  • 基礎結構組態

  • 分佈設定

您可以使用 中的 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 則使用正斜線 (/)。

  2. 使用您建立做為輸入的檔案,執行下列命令。

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