

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

# 修改啟動範本 (管理啟動範本版本)
<a name="manage-launch-template-versions"></a>

啟動範本是不可變的；啟動範本建立後便無法再修改。但是，您可以建立新版本的啟動範本，來包含您需要的任何變更。

您可以建立不同版本的啟動範本、設定預設版本、說明啟動範本版本，以及[刪除您不再需要的版本](delete-launch-template.md#delete-launch-template-version)。

**Topics**
+ [建立啟動範本版本](#create-launch-template-version)
+ [設定預設啟動範本版本](#set-default-launch-template-version)
+ [描述啟動範本版本](#describe-launch-template-version)

## 建立啟動範本版本
<a name="create-launch-template-version"></a>

當您建立啟動範本版本時，可以指定新的啟動參數，或使用現有版本做為新版本的基礎。如需每個參數的描述，請參閱 [Amazon EC2 執行個體組態參數的參考](ec2-instance-launch-parameters.md)。

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

**若要建立啟動範本版本**

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

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

1. 選擇啟動範本，然後選擇**動作**、**修改範本 （建立新版本）**。

1. 在 **Template version description (範本版本描述)** 中，輸入此啟動範本版本的描述。

1. (選取性) 展開 **Source template (來源範本)**，並選取啟動範本的版本，以作為新啟動範本版本的基礎。新啟動範本版本會繼承此啟動範本版本的啟動參數。

1. 視需要修改啟動參數。

1. 選擇 **Create launch template** (建立啟動範本)。

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

**建立啟動範本版本**  
使用 [create-launch-template-version](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-launch-template-version.html) 命令。您可以指定要做為新版本基礎的來源版本。新版本會繼承此版本的啟動參數，但您可以使用 `--launch-template-data` 來覆寫參數。下列範例會建立以第 1 版啟動範本為基礎的新版本，並指定不同的 AMI ID。

```
aws ec2 create-launch-template-version \
    --launch-template-id {{lt-0abcd290751193123}} \
    --version-description {{WebVersion2}} \
    --source-version {{1}} \
    --launch-template-data "ImageId={{ami-0abcdef1234567890}}"
```

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

**建立啟動範本版本**  
使用 [New-EC2LaunchTemplateVersion](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2LaunchTemplateVersion.html) Cmdlet。您可以指定要做為新版本基礎的來源版本。新版本會繼承此版本的啟動參數，但您可以使用 `LaunchTemplateData` 來覆寫參數。下列範例會建立以第 1 版啟動範本為基礎的新版本，並指定不同的 AMI ID。

```
New-EC2LaunchTemplateVersion `
    -LaunchTemplateId {{lt-0abcd290751193123}} `
    -VersionDescription {{WebVersion2}} `
    -SourceVersion {{1}} `
    -LaunchTemplateData (
        New-Object `
            -TypeName Amazon.EC2.Model.RequestLaunchTemplateData `
            -Property @{ImageId = '{{ami-0abcdef1234567890}}'}
    )
```

------

## 設定預設啟動範本版本
<a name="set-default-launch-template-version"></a>

您可以設定啟動範本的預設版本。當您從啟動範本啟動執行個體而且未指定版本時，會使用預設版本的參數來啟動執行個體。

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

**若要設定預設啟動範本版本**

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

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

1. 選擇啟動範本，然後選擇**動作**、**設定預設版本**。

1. 對於 **Template version (範本版本)**，請選取要設為預設版本的版本號碼，然後選取 **Set as default version (設為預設版本)**。

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

**若要設定預設啟動範本版本**  
使用 [modify-launch-template](https://docs.aws.amazon.com/cli/latest/reference/ec2/modify-launch-template.html) 命令。

```
aws ec2 modify-launch-template \
    --launch-template-id {{lt-0abcd290751193123}} \
    --default-version {{2}}
```

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

**若要設定預設啟動範本版本**  
使用 [Edit-EC2LaunchTemplate](https://docs.aws.amazon.com/powershell/latest/reference/items/Edit-EC2LaunchTemplate.html) cmdlet。

```
Edit-EC2LaunchTemplate `
    -LaunchTemplateId {{lt-0abcd290751193123}} `
    -DefaultVersion {{2}}
```

------

## 描述啟動範本版本
<a name="describe-launch-template-version"></a>

您可以使用主控台，檢視所選啟動範本的所有版本，或取得其最新或預設版本符合特定版本號碼之啟動範本的清單。您可以使用 AWS CLI描述指定啟動範本的所有版本、個別版本或一系列版本。您也可以說明帳戶中所有啟動範本的所有最新版本或所有預設版本。

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

**若要描述啟動範本版本**

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

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

1. 您可以檢視特定啟動範本版本，或取得其最新或預設版本符合特定版本號碼之啟動範本的清單。
   + 若要檢視啟動範本的版本：選擇啟動範本。在**版本**索引標籤的**版本**中，選擇版本以檢視其詳細資訊。
   + 若要取得其最新版本符合特定版本號碼之所有啟動範本的清單：請從搜尋列中選擇 **Latest version (最新版本)**，然後選擇版本號碼。
   + 若要取得其預設版本符合特定版本號碼之所有啟動範本的清單：請從搜尋列中選擇 **Default version (預設版本)**，然後選擇版本號碼。

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

**若要描述啟動範本版本**  
使用 [describe-launch-template-versions](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-launch-template-versions.html) 命令，並指定版本號碼。在下列範例中，指定的是第 `{{1}}` 版和第 {{`3`}} 版。

```
aws ec2 describe-launch-template-versions \
    --launch-template-id {{lt-0abcd290751193123}} \
    --versions {{1 3}}
```

**描述帳戶中最新和預設啟動範本版本**  
使用 [describe-launch-template-versions](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-launch-template-versions.html) 命令，並指定 `$Latest`、`$Default` 或兩者。您必須省略呼叫中的啟動範本 ID 和名稱。您無法指定版本號碼。

```
aws ec2 describe-launch-template-versions \
    --versions "{{$Latest}},{{$Default}}"
```

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

**若要描述啟動範本版本**  
使用 [Get-EC2TemplateVersion](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2TemplateVersion.html) Cmdlet，並指定版本編號。在下列範例中，指定的是第 `{{1}}` 版和第 {{`3`}} 版。

```
Get-EC2TemplateVersion `
    -LaunchTemplateId {{lt-0abcd290751193123}} `
    -Version {{1,3}}
```

**描述帳戶中最新和預設啟動範本版本**  
使用 [Get-EC2TemplateVersion](https://docs.aws.amazon.com/powershell/latest/reference/items/Get-EC2TemplateVersion.html) Cmdlet，並指定 `$Latest` 和/或 `$Default`。您必須省略呼叫中的啟動範本 ID 和名稱。您無法指定版本號碼。

```
Get-EC2TemplateVersion `
    -Version '{{$Latest}}','{{$Default}}'
```



------