

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

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

您可以為執行個體組態參數指定自己的值，或是從現有的啟動範本或 Amazon EC2 執行個體取得值，藉此建立 Amazon EC2 啟動範本。

您不需要為啟動範本中的每個參數指定值；您只需指定一個執行個體組態參數即可建立啟動範本。若要表示您選擇不指定的參數，在使用主控台時，請選取**不要包含在啟動範本中**。使用命令列工具時，請勿包含參數，以表示您要選取不要將參數包含在啟動範本中。

如果您想要在啟動範本中指定 AMI，可以選取 AMI，或指定 Systems Manager 參數，以在執行個體啟動時指向 AMI。

使用啟動範本啟動執行個體時，會將啟動範本中所指定的值用來設定對應的執行個體參數。如果未在啟動範本中指定值，則會使用對應執行個體參數的預設值。

**Topics**
+ [指定參數來建立啟動範本](#create-launch-template-define-parameters)
+ [從現有啟動範本建立啟動範本](#create-launch-template-from-existing-launch-template)
+ [從執行個體建立啟動範本](#create-launch-template-from-instance)
+ [使用 Systems Manager 參數而非 AMI ID](#use-an-ssm-parameter-instead-of-an-ami-id)

## 指定參數來建立啟動範本
<a name="create-launch-template-define-parameters"></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 (啟動範本)** 接著選擇 **Create launch template (建立啟動範本)**。

1. 在**啟動範本名稱和描述**下，執行下列動作：

   1. 針對 **Launch template name (啟動範本名稱)**，輸入啟動範本的描述性名稱。

   1. 在 **Template version description (範本版本描述)** 中，提供此啟動範本版本的簡短描述。

   1. 若要在建立時[標記](Using_Tags.md)啟動範本，請展開**範本標籤**、選擇**新增標籤**，然後輸入標籤鍵值組。為每個要新增的其他標籤重新選擇**新增新的標籤**。
**注意**  
要標記啟動執行個體時建立的資源，您必須在 **Resource tags** (資源標籤) 下指定標籤。如需詳細資訊，請參閱程序中的步驟 9。

1. 您可以在**應用程式和作業系統映像 (Amazon Machine Image)** 下，保持選取**不要包含在啟動範本中**，或選擇執行個體的作業系統 (OS)，然後選擇 AMI。或者，您可以指定 Systems Manager 參數，而非指定 AMI。如需詳細資訊，請參閱[使用 Systems Manager 參數而非 AMI ID](#use-an-ssm-parameter-instead-of-an-ami-id)。

   AMI 是一種包含啟動執行個體所需作業系統和軟體的範本。

1. 對於**執行個體類型**，您可以保持選取**不要包含在啟動範本中**，或是選取執行個體類型，或者指定執行個體屬性，並讓 Amazon EC2 利用這些屬性識別執行個體類型。
**注意**  
只有在 Auto Scaling 群組、EC2 機群和 Spot 機群使用啟動範本啟動執行個體時，才支援指定執行個體屬性。如需詳細資訊，請參閱[使用參數型執行個體類型選項建立混合執行個體群組](https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-mixed-instances-group-attribute-based-instance-type-selection.html)和 [指定屬性，為 EC2 機群或 Spot 機群選取執行個體類型](ec2-fleet-attribute-based-instance-type-selection.md)。  
如果您打算在[啟動執行個體精靈](ec2-launch-instance-wizard.md)中使用啟動範本，或與 [RunInstances API](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_RunInstances.html) 搭配使用，則您無法指定執行個體類型屬性。

   執行個體類型會決定硬體組態 (CPU、記憶體、儲存體和聯網容量)，以及執行個體所使用主機電腦的大小。

   如果您不確定要選擇哪個執行個體類型，可以執行下列動作：
   + 選擇**比較執行個體類型**，依下列屬性比較不同的執行個體類型：vCPU 數目、架構、記憶體數量 (GiB)、儲存數量 (GB)、儲存類型，以及網路效能。
   + 選擇**取得建議**，以從 EC2 執行個體類型搜尋工具取得執行個體類型的指導和建議。如需詳細資訊，請參閱[從 EC2 執行個體類型搜尋工具取得建議](get-ec2-instance-type-recommendations.md)。
**注意**  
視您建立帳戶的時間而定，您可能有資格使用免費方案下的 Amazon EC2。  
如果您的 是在 2025 年 7 月 15 AWS 帳戶 日之前建立的，而且還不到 12 個月，您可以在無法使用 t2.micro 的區域中選取 **t2.micro** 執行個體類型或 t3.micro 執行個體類型，在 免費方案下使用 Amazon EC2。 **** ****請注意，當您啟動 **t3.micro** 執行個體時，其會預設為[**無限制**模式](burstable-performance-instances-unlimited-mode.md)，且依據 CPU 用量而定，這可能會產生額外費用。如果某個執行個體類型可用於免費方案，則標記為**符合免費方案條件**。  
如果您在 2025 年 7 月 15 日 AWS 帳戶 或之後建立 ，則可以使用 **t3.micro**、**t3.small**、**t4g.micro**、**t4g.small**、**c7i-flex.large** 和 **m7i-flex.large** 執行個體類型 6 個月，或直到您的點數用完為止。  
如需詳細資訊，請參閱[2025 年 7 月 15 日之前和之後的免費方案優惠](ec2-free-tier-usage.md#ec2-free-tier-comparison)。

1. 在**金鑰對 (登入)** 下，針對**金鑰對名稱**，請保留選取**不要包含在啟動範本中**，或選擇現有的金鑰對，或者建立新的金鑰對。

1. 在**網路設定**下，您可以保持選取**不要包含在啟動範本中**，也可以指定各種網路設定的值。

1. 在**設定儲存**下，如果您在啟動範本中指定 AMI，則 AMI 會包含一或多個儲存磁碟區，包含根磁碟區 (**Volume 1 (AMI Root)**)。您可以選擇指定要連接至執行個體的其他磁碟區。若要新增磁碟區，請選擇 **Add new volume (新增磁碟區)**。

1. 在**資源標籤**下，若要[標記](Using_Tags.md)啟動執行個體時所建立的資源，請選擇**新增標籤**，然後輸入標籤鍵值組。針對 **Resource types** (資源類型)，請指定建立時要標記的資源。您可以為所有資源指定相同的標籤，或者為不同的資源指定不同的標籤。為每個要新增的其他標籤重新選擇 **Add tag** (新增標籤)。

   您可以針對使用啟動範本時建立的以下資源指定標籤：
   + 執行個體
   + 磁碟區
   + Elastic Graphics
   + Spot 執行個體請求
   + 網路介面
**注意**  
若要標記啟動範本本身，您必須在 **Template tags** (範本標籤) 下指定標籤。如需詳細資訊，請參閱程序中的步驟 3。

1. 針對**進階詳細資訊**，展開此區段來檢視欄位，並選擇指定執行個體的任何其他參數。

1. 使用**摘要**面板來檢閱啟動範本組態。您可以選擇區段的連結，然後進行任何必要的變更，以導覽至任何區段。

1. 當您準備好建立啟動範本時，請選擇 **Create launch template** (建立啟動範本)。

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

**建立啟動範本**  
使用 [create-launch-template](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-launch-template.html) 命令。

```
aws ec2 create-launch-template \
    --launch-template-name TemplateForWebServer \
    --version-description WebVersion1 \
    --tag-specifications 'ResourceType=launch-template,Tags=[{Key=purpose,Value=production}]' \
    --launch-template-data file://template-data.json
```

以下是範例 JSON，會指定執行個體組態的啟動範本資料。將 JSON 儲存到檔案，並將其包含在 `--launch-template-data` 參數中，如範例命令所示。

```
{
    "NetworkInterfaces": [{
        "AssociatePublicIpAddress": true,
        "DeviceIndex": 0,
        "Ipv6AddressCount": 1,
        "SubnetId": "subnet-0abcdef1234567890"
    }],
    "ImageId": "ami-0abcdef1234567890",
    "InstanceType": "r5.4xlarge",
    "TagSpecifications": [{
        "ResourceType": "instance",
        "Tags": [{
            "Key":"Name",
            "Value":"webserver"
        }]
    }],
    "CpuOptions": {
        "CoreCount":4,
        "ThreadsPerCore":2
    }
}
```

以下為範例輸出。

```
{
    "LaunchTemplate": {
        "LatestVersionNumber": 1, 
        "LaunchTemplateId": "lt-01238c059e3466abc", 
        "LaunchTemplateName": "TemplateForWebServer", 
        "DefaultVersionNumber": 1, 
        "CreatedBy": "arn:aws:iam::123456789012:root", 
        "CreateTime": "2017-11-27T09:13:24.000Z"
    }
}
```

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

**建立啟動範本**  
使用 [New-EC2LaunchTemplate](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2LaunchTemplate.html) cmdlet。

```
$launchTemplateData = [Amazon.EC2.Model.RequestLaunchTemplateData]@{
    ImageId = 'ami-0abcdef1234567890'
    InstanceType = 'r5.4xlarge'
    NetworkInterfaces = @(
        [Amazon.EC2.Model.LaunchTemplateInstanceNetworkInterfaceSpecificationRequest]@{
            AssociatePublicIpAddress = $true
            DeviceIndex = 0
            Ipv6AddressCount = 1
            SubnetId = 'subnet-0abcdef1234567890'
        }
    )
    TagSpecifications = @(
        [Amazon.EC2.Model.LaunchTemplateTagSpecificationRequest]@{
            ResourceType = 'instance'
            Tags = [Amazon.EC2.Model.Tag]@{
                Key = 'Name'
                Value = 'webserver'
            }
        }
    )
    CpuOptions = [Amazon.EC2.Model.LaunchTemplateCpuOptionsRequest]@{
        CoreCount = 4
        ThreadsPerCore = 2
    }
}
$tagSpecificationData = [Amazon.EC2.Model.TagSpecification]@{
    ResourceType = 'launch-template'
    Tags = [Amazon.EC2.Model.Tag]@{
        Key = 'purpose'
        Value = 'production'
    }
}
New-EC2LaunchTemplate -LaunchTemplateName 'TemplateForWebServer' `
    -VersionDescription 'WebVersion1' `
    -LaunchTemplateData $launchTemplateData `
    -TagSpecification $tagSpecificationData
```

以下為範例輸出。

```
CreatedBy            : arn:aws:iam::123456789012:root
CreateTime           : 9/19/2023 16:57:55
DefaultVersionNumber : 1
LatestVersionNumber  : 1
LaunchTemplateId     : lt-01238c059eEXAMPLE
LaunchTemplateName   : TemplateForWebServer
Tags                 : {purpose}
```

------

## 從現有啟動範本建立啟動範本
<a name="create-launch-template-from-existing-launch-template"></a>

您可以複製現有啟動範本，然後調整參數以建立新版啟動範本。不過，您只能在使用 Amazon EC2 主控台時執行這項操作。 AWS CLI 不支援複製範本。如需每個參數的描述，請參閱 [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 (啟動範本)** 接著選擇 **Create launch template (建立啟動範本)**。

1. 針對 **Launch template name (啟動範本名稱)**，輸入啟動範本的描述性名稱。

1. 在 **Template version description (範本版本描述)** 中，提供此啟動範本版本的簡短描述。

1. 若要在建立時標記啟動範本，請展開**範本標籤**、選擇**新增標籤**，然後輸入標籤鍵值組。

1. 展開**來源範本**，並針對**啟動範本名稱**，選擇要以新啟動範本為基礎的啟動範本。

1. 針對 **Source template version (來源範本版本)**，選擇要做為新啟動範本基礎的啟動範本版本。

1. 視需要調整任何啟動參數，然後選擇 **Create launch template (建立啟動範本)**。

------

## 從執行個體建立啟動範本
<a name="create-launch-template-from-instance"></a>

您可以複製現有 Amazon EC2 執行個體的參數，然後調整參數來建立啟動範本。如需每個參數的描述，請參閱 [Amazon EC2 執行個體組態參數的參考](ec2-instance-launch-parameters.md)。

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

**若要從執行個體建立啟動範本**

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

1. 在導覽窗格中，選擇**執行個體**。

1. 選取執行個體，然後選擇**動作**、**映像和範本**、**從執行個體建立範本**。

1. 提供名稱、描述和標籤，並視需要調整啟動參數。
**注意**  
當您從執行個體建立啟動範本時，範本不包含執行個體的網路介面 ID 和 IP 地址。

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

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

您可以使用 從現有執行個體 AWS CLI 建立啟動範本，方法是先從執行個體取得啟動範本資料，然後使用啟動範本資料建立啟動範本。

**若要從執行個體啟動範本資料**
+ 使用 [get-launch-template-data](https://docs.aws.amazon.com/cli/latest/reference/ec2/get-launch-template-data.html) 命令，並指定執行個體 ID。您能以輸出做為基礎，用以建立新啟動範本或啟動範本版本。根據預設，輸出包括最上層 `LaunchTemplateData` 物件，而此物件無法於啟動範本資料中指定。使用 `--query` 選項排除此物件。

  ```
  aws ec2 get-launch-template-data \
      --instance-id i-0123d646e8048babc \
      --query "LaunchTemplateData"
  ```

  下列為範例輸出。

  ```
      {
          "Monitoring": {}, 
          "ImageId": "ami-8c1be5f6", 
          "BlockDeviceMappings": [
              {
                  "DeviceName": "/dev/xvda", 
                  "Ebs": {
                      "DeleteOnTermination": true
                  }
              }
          ], 
          "EbsOptimized": false, 
          "Placement": {
              "Tenancy": "default", 
              "GroupName": "", 
              "AvailabilityZone": "us-east-1a"
          }, 
          "InstanceType": "t2.micro", 
          "NetworkInterfaces": [
              {
                  "Description": "", 
                  "NetworkInterfaceId": "eni-35306abc", 
                  "PrivateIpAddresses": [
                      {
                          "Primary": true, 
                          "PrivateIpAddress": "10.0.0.72"
                      }
                  ], 
                  "SubnetId": "subnet-7b16de0c", 
                  "Groups": [
                      "sg-7c227019"
                  ], 
                  "Ipv6Addresses": [
                      {
                          "Ipv6Address": "2001:db8:1234:1a00::123"
                      }
                  ], 
                  "PrivateIpAddress": "10.0.0.72"
              }
          ]
      }
  ```

  例如，您可以將輸出直接寫入檔案：

  ```
  aws ec2 get-launch-template-data \
      --instance-id i-0123d646e8048babc \
      --query "LaunchTemplateData" >> instance-data.json
  ```

**使用啟動範本資料建立啟動範本**
+ 使用 [create-launch-template](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-launch-template.html) 命令，使用上一個程序的輸出建立啟動範本。如需使用 建立啟動範本的詳細資訊 AWS CLI，請參閱 [指定參數來建立啟動範本](#create-launch-template-define-parameters)。

------

## 使用 Systems Manager 參數而非 AMI ID
<a name="use-an-ssm-parameter-instead-of-an-ami-id"></a>

您可以指定 AWS Systems Manager 參數，而非在啟動範本中指定 AMI ID。如果 AMI ID 變更，則您可以透過更新 Systems Manager 參數存放區中的 Systems Manager 參數，在一個位置更新 AMI ID。參數也可以與其他 [共用](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-shared-parameters.html) AWS 帳戶。您可以將 AMI 參數集中存放在一個帳戶中並進行管理，並與需要參考這些參數的所有其他帳戶共用。透過使用 Systems Manager 參數，您可以在單一動作中更新所有啟動範本。

Systems Manager 參數是使用者定義的鍵值對，您可以在 [AWS Systems Manager 參數存放區](https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html)中建立。參數存放區提供一個中央位置來存放應用程式組態值。

在下圖中，`golden-ami` 參數首先映射到參數存放區中的原始 AMI `ami-aabbccddeeffgghhi`。在啟動範本中，AMI ID 的值為 `golden-ami`。使用此啟動範本啟動執行個體時，AMI ID 會解析為 `ami-aabbccddeeffgghhi`。稍後，會更新 AMI，從而產生新的 AMI ID。在參數存放區中，`golden-ami` 參數會映射至新的 `ami-00112233445566778`。*啟動範本保持不變。*使用此啟動範本啟動執行個體時，AMI ID 會解析為新的 `ami-00112233445566778`。

![\[使用參數存放區中的 Systems Manager 參數來更新啟動範本。\]](http://docs.aws.amazon.com/zh_tw/AWSEC2/latest/UserGuide/images/launch-template-ami-alias.png)


### AMI ID 的 Systems Manager 參數格式
<a name="ssm-parameter-format-for-ami-ids"></a>

啟動範本要求使用者定義的 Systems Manager 參數在用於取代 AMI ID 時必須遵循下列格式：
+ 參數類型：`String`
+ 參數資料類型：`aws:ec2:image` - 這可確保參數存放區驗證您輸入的值是否為格式正確的 AMI ID 。

如需有關為 AMI ID 建立有效參數的詳細資訊，請參閱「AWS Systems Manager 使用者指南」**中的[建立 Systems Manager 參數](https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-paramstore-su-create.html)。

### 啟動範本中的 Systems Manager 參數格式
<a name="ssm-parameter-format-in-launch-templates"></a>

若要使用 Systems Manager 參數取代啟動範本中的 AMI ID，在啟動範本中指定參數時，必須使用下列其中一種格式：

若要參考公用參數：
+ `resolve:ssm:public-parameter`

若要參考存放在相同帳戶中的參數：
+ `resolve:ssm:parameter-name`
+ `resolve:ssm:parameter-name:version-number` - 版本編號本身是預設標籤
+ `resolve:ssm:parameter-name:label`

若要參考從另一個 AWS 帳戶共用的參數：
+ `resolve:ssm:parameter-ARN`
+ `resolve:ssm:parameter-ARN:version-number`
+ `resolve:ssm:parameter-ARN:label`

**參數版本**

Systems Manager 參數是版本化資源。更新參數時，會建立新的連續參數版本。Systems Manager 支援[參數標籤](https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-paramstore-labels.html)，您可以將其映射至特定參數版本。

例如，`golden-ami` 參數可以有三個版本：`1`、`2` 和 `3`。您可以建立映射至版本 `2` 的參數標籤 `beta`，以及映射至版本 `3` 的參數標籤 `prod`。

在啟動範本中，可以使用下列其中一種格式來指定 `golden-ami` 參數的版本 3：
+ `resolve:ssm:golden-ami:3`
+ `resolve:ssm:golden-ami:prod`

指定版本或標籤是可選操作。如果未指定版本或標籤，則會使用最新版本的參數。

### 在啟動範本中指定 Systems Manager 參數
<a name="specify-systems-manager-parameter-in-launch-template"></a>

建立啟動範本或新版本的啟動範本時，可以在啟動範本中指定 Systems Manager 參數，而非 AMI ID。

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

**在啟動範本中指定 Systems Manager 參數**

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

1. 在導覽窗格中，選擇 **Launch Templates (啟動範本)** 接著選擇 **Create launch template (建立啟動範本)**。

1. 針對 **Launch template name (啟動範本名稱)**，輸入啟動範本的描述性名稱。

1. 在 **Application and OS Images (Amazon Machine Image)** (應用程式和作業系統映像 (Amazon Machine Image)) 下，選擇 **Browse more AMIs** (瀏覽更多 AMI)。

1. 選擇搜尋列右側的箭頭按鈕，然後選擇**指定自訂值/Systems Manager 參數**。

1. 在**指定自訂值或 Systems Manager 參數**對話方塊中，執行下列操作：

   1. 對於 **AMI ID 或 Systems Manager 參數字串**，請使用下列其中一種格式輸入 Systems Manager 參數名稱：

      若要參考公用參數：
      + **resolve:ssm:*public-parameter***

      若要參考存放在相同帳戶中的參數：
      + **resolve:ssm:*parameter-name***
      + **resolve:ssm:*parameter-name*:*version-number***
      + **resolve:ssm:*parameter-name*:*label***

      若要參考從另一個 AWS 帳戶共用的參數：
      + **resolve:ssm:*parameter-ARN***
      + **resolve:ssm:*parameter-ARN*:*version-number***
      + **resolve:ssm:*parameter-ARN*:*label***

   1. 選擇**儲存**。

1. 視需要指定任何其他啟動範本參數，然後選擇**建立啟動範本**。

如需詳細資訊，請參閱[指定參數來建立啟動範本](#create-launch-template-define-parameters)。

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

**在啟動範本中指定 Systems Manager 參數**
+ 使用 [create-launch-template](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-launch-template.html) 命令，建立啟動範本。若要指定要使用的 AMI，請使用下列其中一種格式輸入 Systems Manager 參數名稱：

  若要參考公用參數：
  + **resolve:ssm:*public-parameter***

  若要參考存放在相同帳戶中的參數：
  + **resolve:ssm:*parameter-name***
  + **resolve:ssm:*parameter-name*:*version-number***
  + **resolve:ssm:*parameter-name*:*label***

  若要參考從另一個 AWS 帳戶共用的參數：
  + **resolve:ssm:*parameter-ARN***
  + **resolve:ssm:*parameter-ARN*:*version-number***
  + **resolve:ssm:*parameter-ARN*:*label***

  以下範例建立的啟動範本會指定下列項目：
  + 啟動範本的名稱 (`TemplateForWebServer`)
  + 啟動範本的標籤 (`purpose`=`production`)
  + 在 JSON 檔案中指定的執行個體組態的資料：
    + 要使用的 AMI (`resolve:ssm:golden-ami`)
    + 要啟動的執行個體類型 (`m5.4xlarge`)
    + 執行個體的標籤 (`Name`=`webserver`)

  ```
  aws ec2 create-launch-template \
      --launch-template-name TemplateForWebServer \
      --tag-specifications 'ResourceType=launch-template,Tags=[{Key=purpose,Value=production}]' \
      --launch-template-data file://template-data.json
  ```

  以下是一個範例 JSON 檔案，其中包含執行個體組態的啟動範本資料。`ImageId` 的值為 Systems Manager 參數名稱，以所需格式 `resolve:ssm:golden-ami` 輸入。

  ```
  {"LaunchTemplateData": {
      "ImageId": "resolve:ssm:golden-ami",
      "InstanceType": "m5.4xlarge",
      "TagSpecifications": [{
          "ResourceType": "instance",
          "Tags": [{
              "Key":"Name",
              "Value":"webserver"
          }]
      }]
    }
  }
  ```

------

### 確認啟動範本取得正確的 AMI ID
<a name="ssm-parameter-verify-ami-id"></a>

**將 Systems Manager 參數解析為實際 AMI ID**  
使用 [describe-launch-template-versions](https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-launch-template-versions.html) 命令，並包含 `--resolve-alias` 參數。

```
aws ec2 describe-launch-template-versions \
    --launch-template-name my-launch-template \
    --versions $Default \
    --resolve-alias
```

回應包含 `ImageId` 的 AMI ID。在此範例中，使用此啟動範本啟動執行個體時，AMI ID 會解析為 `ami-0ac394d6a3example`。

```
{
    "LaunchTemplateVersions": [
        {
            "LaunchTemplateId": "lt-089c023a30example",
            "LaunchTemplateName": "my-launch-template",
            "VersionNumber": 1,
            "CreateTime": "2022-12-28T19:52:27.000Z",
            "CreatedBy": "arn:aws:iam::123456789012:user/Bob",
            "DefaultVersion": true,
            "LaunchTemplateData": {
                "ImageId": "ami-0ac394d6a3example",
                "InstanceType": "t3.micro",
            }
        }
    ]
}
```

### 相關資源
<a name="ssm-parameter-related-resources"></a>

如需關於使用 Systems Manager 參數的詳細資訊，請參閱 Systems Manager 文件中的下列參考資料。
+ 如需如何查詢 Amazon EC2 所支援 AMI 公用參數的詳細資訊，請參閱[呼叫 AMI 公用參數](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-public-parameters-ami.html)。
+ 如需與其他 AWS 帳戶或透過 共用參數的詳細資訊 AWS Organizations，請參閱[使用共用參數](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-shared-parameters.html)。
+ 如需監控參數是否已成功建立的相關資訊，請參閱「Amazon Machine Image ID 的原生參數支援」[https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-ec2-aliases.html](https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-ec2-aliases.html)。

### 限制
<a name="ssm-parameter-limitations"></a>
+ 只有 `instant` 類型的 EC2 機群支援使用具有指定 Systems Manager 參數來取代 AMI ID 的啟動範本。
+ 目前，`maintain` 和 `request` 類型的 EC2 機群以及 Spot 機群不支援使用具有指定 Systems Manager 參數來取代 AMI ID 的啟動範本。對於 `maintain` 和 `request` 類型的 EC2 機群以及 Spot 機群，如果您在啟動範本中指定 AMI，則必須指定 AMI ID。
+ 如果您在 EC2 機群中使用[屬性型執行個體選擇](ec2-fleet-attribute-based-instance-type-selection.md)，則無法指定 Systems Manager 參數來取代 AMI ID。您在使用屬性型執行個體選擇時，必須指定 AMI ID。
+ Amazon EC2 Auto Scaling 會提供其他限制。如需詳細資訊，請參閱《*Amazon EC2 Auto Scaling 使用者指南*》[中的在啟動範本中使用 AWS Systems Manager 參數而非 AMI IDs](https://docs.aws.amazon.com/autoscaling/ec2/userguide/using-systems-manager-parameters.html)。