View a markdown version of this page

使用試轉驗證映像建置器資源建立 - EC2 Image Builder

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

使用試轉驗證映像建置器資源建立

透過試轉,您可以檢查建立 Image Builder 資源的請求是否成功,而無需建立資源。當您在請求true中將 dryRun 參數設定為 時,Image Builder 會驗證所需的許可和請求參數,然後在建立任何項目之前停止。結果是下列其中一項:

  • 如果驗證成功,請求會失敗並顯示DryRunOperationException錯誤。此錯誤表示請求有效,且資源建立將在沒有 dryRun 參數的情況下成功。

  • 如果驗證失敗,請求會傳回在沒有 dryRun 參數的情況下會傳回的相同錯誤,例如 InvalidParameterValueException或 ResourceAlreadyExistsException。

在這兩種情況下,Image Builder 都不會建立資源。乾執行可讓您立即獲得資源組態的意見回饋。這對於建立映像建置器資源的自動化和 AI 代理器特別有用。這類工具可以在建立任何內容之前驗證每個組態並更正錯誤。

下列建立動作支援 dryRun 參數:

  • CreateComponent

  • CreateContainerRecipe

  • CreateDistributionConfiguration

  • CreateImagePipeline

  • CreateImageRecipe

  • CreateInfrastructureConfiguration

  • CreateLifecyclePolicy

  • CreateWorkflow

注意

CreateImage 動作不支援 dryRun 參數,因為它會啟動映像組建,而不是建立組態資源。

從 執行試轉 AWS CLI

下列範例顯示如何使用 create-infrastructure-configuration命令驗證基礎設施組態。--dry-run 選項會將請求轉換為試轉。

aws imagebuilder create-infrastructure-configuration \ --name my-example-infrastructure-configuration \ --instance-profile-name EC2InstanceProfileForImageBuilder \ --dry-run

如果組態有效,命令會傳回下列錯誤,以顯示請求會成功。

An error occurred (DryRunOperationException) when calling the CreateInfrastructureConfiguration operation: Request would have succeeded, but dryRun flag is set.