View a markdown version of this page

删除过期或未使用的 Image Builder 资源 - EC2 Image Builder
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)。

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

删除过期或未使用的 Image Builder 资源

Image Builder 环境就像家一样,需要定期维护,以帮助您找到所需的内容,并在不费吹灰之力的情况下完成任务。请务必定期对为了测试而创建的临时资源进行清理。否则,您可能会忘记这些资源,然后再也不记得它们的用途。届时,可能还不清楚你能否安全地删除它们。

删除资源不会删除在映像构建过程中创建的任何 Amazon EC2 AMI 或 Amazon ECR 容器映像。您必须使用相应的 Amazon EC2 或 Amazon ECR 控制台操作、API 或 Amazon CLI 命令。

提示

为防止在删除资源时出现依赖项错误,请确保按以下顺序删除资源:

  1. 映像管道

  2. 映像配方

  3. 所有剩余的资源

删除映像管道

Console
删除管道
  1. 要查看在您的账户下创建的构建管道列表,请从导航窗格中选择映像管道。

  2. 导航到 镜像管道 页面,然后选中要删除的管道名称旁边的复选框。

  3. 在映像管道面板顶部的操作菜单中,选择删除。

  4. 若要确认删除,请在框中输入 Delete,然后选择删除。

Amazon CLI

以下示例显示如何通过指定图像管道的 ARN 来删除图像管道:

aws imagebuilder delete-image-pipeline --image-pipeline-arn arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/my-example-pipeline
PowerShell

以下示例显示如何使用 Remove-EC2IBImagePipeline cmdlet 通过指定图像管道的亚马逊资源名称 (ARN) 来删除图像管道:

Remove-EC2IBImagePipeline -ImagePipelineArn arn:aws:imagebuilder:us-west-2:123456789012:image-pipeline/my-example-pipeline

删除镜像配方

Console
删除配方
  1. 要查看在您的账户下创建的配方列表,请从导航窗格中选择映像配方。

  2. 选择配方名称旁边的复选框以选择想要删除的配方。

  3. 在映像配方面板顶部的操作菜单中,选择删除配方。

  4. 若要确认删除,请在框中输入 Delete,然后选择删除。

Amazon CLI

以下示例显示如何通过指定图像配方的 ARN 来删除图像配方:

aws imagebuilder delete-image-recipe --image-recipe-arn arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/my-example-recipe/2019.12.03
PowerShell

以下示例显示了如何使用 Remove-EC2IBImageRecipe cmdlet 通过指定其亚马逊资源名称 (ARN) 来删除图片配方:

Remove-EC2IBImageRecipe -ImageRecipeArn arn:aws:imagebuilder:us-west-2:123456789012:image-recipe/my-example-recipe/2019.12.03

删除容器配方

Console
删除容器配方
  1. 要查看在您的账户下创建的容器配方列表,请从导航窗格中选择容器配方。

  2. 选择配方名称旁边的复选框以选择想要删除的配方。

  3. 在容器配方面板顶部的操作菜单中,选择删除配方。

  4. 若要确认删除,请在框中输入 Delete,然后选择删除。

Amazon CLI

以下示例显示如何通过指定容器配方的 ARN 来删除容器配方:

aws imagebuilder delete-container-recipe --container-recipe-arn arn:aws:imagebuilder:us-west-2:123456789012:container-recipe/my-example-container-recipe/1.0.0
PowerShell

以下示例显示了如何使用 Remove-EC2IBContainerRecipe cmdlet 通过指定容器配方的亚马逊资源名称 (ARN) 来删除容器配方:

Remove-EC2IBContainerRecipe -ContainerRecipeArn arn:aws:imagebuilder:us-west-2:123456789012:container-recipe/my-example-container-recipe/1.0.0

删除基础设施配置

Console
删除基础设施配置
  1. 要查看在您的账户下创建的基础设施配置列表,请从导航窗格中选择基础设施配置。

  2. 选择配置名称旁边的复选框以选择想要删除的基础架构配置。

  3. 在基础设施配置面板的顶部,选择删除。

  4. 若要确认删除,请在框中输入 Delete,然后选择删除。

Amazon CLI

以下示例显示如何通过指定基础架构配置资源的 ARN 来删除该资源:

aws imagebuilder delete-infrastructure-configuration --infrastructure-configuration-arn arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/my-example-infrastructure-configuration
PowerShell

以下示例显示了如何使用 Remove-EC2IBInfrastructureConfiguration cmdlet 通过指定基础设施配置资源的亚马逊资源名称 (ARN) 来删除该资源:

Remove-EC2IBInfrastructureConfiguration -InfrastructureConfigurationArn arn:aws:imagebuilder:us-west-2:123456789012:infrastructure-configuration/my-example-infrastructure-configuration

删除分配设置

Console
删除分配设置
  1. 要查看在您的账户下创建的分配设置列表,请从导航窗格中选择分配设置。

  2. 选择配置名称旁边的复选框以选择您为本教程创建的分配设置。

  3. 在分配设置面板的顶部,选择删除。

  4. 若要确认删除,请在框中输入 Delete,然后选择删除。

Amazon CLI

以下示例显示如何通过指定分配设置资源的 ARN 来删除该资源:

aws imagebuilder delete-distribution-configuration --distribution-configuration-arn arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/my-example-distribution-configuration
PowerShell

以下示例显示了如何使用 Remove-EC2IBDistributionConfiguration cmdlet 通过指定分配设置资源的亚马逊资源名称 (ARN) 来删除该资源:

Remove-EC2IBDistributionConfiguration -DistributionConfigurationArn arn:aws:imagebuilder:us-west-2:123456789012:distribution-configuration/my-example-distribution-configuration

删除映像

Console
  1. 要查看在您的账户下创建的映像列表,请从导航窗格中选择映像。

  2. 对于要移除的映像,选择映像版本。此时将打开映像构建版本页面。

  3. 选中要删除的任何图像的版本旁边的复选框。您一次可以选择多个映像版本。

  4. 在映像构建版本面板的顶部,选择删除版本。

  5. 若要确认删除,请在框中输入 Delete,然后选择删除。

Amazon CLI

以下示例显示如何通过指定映像编译版本的 ARN 来删除该版本:

aws imagebuilder delete-image --image-build-version-arn arn:aws:imagebuilder:us-west-2:123456789012:image/my-example-image/2019.12.02/1
PowerShell

以下示例显示了如何使用 Remove-EC2IBImage cmdlet 通过指定其亚马逊资源名称 (ARN) 来删除映像构建版本:

Remove-EC2IBImage -ImageBuildVersionArn arn:aws:imagebuilder:us-west-2:123456789012:image/my-example-image/2019.12.02/1

删除组件

重要

在删除组件构建版本之前,请确保没有任何配方以任何方式引用该版本。否则,可能会导致管道故障。

Amazon CLI

以下示例显示如何通过指定组件编译版本的 ARN 来删除该版本:

aws imagebuilder delete-component --component-build-version-arn arn:aws:imagebuilder:us-west-2:123456789012:component/my-example-component/2019.12.02/1
PowerShell

以下示例显示了如何使用 Remove-EC2IBComponent cmdlet 通过指定组件的亚马逊资源名称 (ARN) 来删除组件构建版本:

Remove-EC2IBComponent -ComponentBuildVersionArn arn:aws:imagebuilder:us-west-2:123456789012:component/my-example-component/2019.12.02/1