

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

# 刪除啟動範本或啟動範本版本
<a name="delete-launch-template"></a>

如果您不再需要啟動範本，即可將其刪除。刪除啟動範本會刪除它的所有版本。如果您只想要刪除特定版本的啟動範本，可以在保留其他版本啟動範本的情況下執行此操作。

刪除啟動範本或啟動範本版本，並不會影響您從啟動範本啟動的任何執行個體。

## 刪除啟動範本以及其所有版本
<a name="delete-launch-template-including-versions"></a>

如果您不再需要啟動範本，包括其所有版本，可以刪除啟動範本。刪除啟動範本會刪除它的所有版本。

------
#### [ Console ]

**刪除啟動範本及其所有版本**

1. 前往 [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/) 開啟 Amazon EC2 主控台。

1. 在導覽窗格中，選擇 **Launch Templates (啟動範本)**。

1. 選取啟動範本，然後選取 **Actions (動作)**、**Delete template (刪除範本)**。

1. 輸入 **Delete** 以確認刪除，然後選擇 **Delete (刪除)**。

------
#### [ AWS CLI ]

**刪除啟動範本及其所有版本**  
使用 [delete-launch-template](https://docs.aws.amazon.com/cli/latest/reference/ec2/delete-launch-template.html) 命令，並指定啟動範本。

```
aws ec2 delete-launch-template --launch-template-id lt-01238c059e3466abc
```

------
#### [ PowerShell ]

**刪除啟動範本及其所有版本**  
使用 [Remove-EC2LaunchTemplate](https://docs.aws.amazon.com/powershell/latest/reference/items/Remove-EC2LaunchTemplate.html) (AWS Tools for PowerShell) 命令，並指定啟動範本。如果省略 `-Force`，則 PowerShell 會提示進行確認。

```
Remove-EC2LaunchTemplate -LaunchTemplateId lt-0123456789example -Force
```

------

## 刪除啟動範本版本
<a name="delete-launch-template-version"></a>

如果您不再需要啟動範本版本，可以將其刪除。

**考量事項**
+ 版本號碼在刪除之後就無法取代。
+ 您無法刪除啟動範本的預設版本；您必須先指派不同的版本作為預設值。如果預設版本是啟動範本的唯一版本，則須[刪除整個啟動範本](#delete-launch-template)。
+ 使用主控台時，您一次可以刪除一個啟動範本版本。使用 時 AWS CLI，您可以在單一請求中刪除最多 200 個啟動範本版本。若要在單個請求中刪除超過 200 個版本，您可以[刪除啟動範本](#delete-launch-template)，而這也會刪除啟動範本的所有版本。

------
#### [ Console ]

**若要刪除啟動範本版本**

1. 前往 [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/) 開啟 Amazon EC2 主控台。

1. 在導覽窗格中，選擇 **Launch Templates (啟動範本)**。

1. 選取啟動範本，然後選取 **Actions (動作)**、**Delete template version (刪除範本版本)**。

1. 選取要刪除的版本，然後選取 **Delete (刪除)**。

------
#### [ AWS CLI ]

**若要刪除啟動範本版本**  
使用 [delete-launch-template-versions](https://docs.aws.amazon.com/cli/latest/reference/ec2/delete-launch-template-versions.html) 命令，並指定要刪除的版本號碼。您在單個請求中最多可刪除 200 個啟動範本版本。

```
aws ec2 delete-launch-template-versions \
    --launch-template-id lt-0abcd290751193123 \
    --versions 1
```

------
#### [ PowerShell ]

**刪除啟動範本版本**  
使用 [Remove-EC2TemplateVersion](https://docs.aws.amazon.com/powershell/latest/reference/items/Remove-EC2TemplateVersion.html) cmdlet，並指定要刪除的版本編號。您在單個請求中最多可刪除 200 個啟動範本版本。

```
Remove-EC2TemplateVersion `
    -LaunchTemplateId lt-0abcd290751193123 `
    -Version 1
```

------