All Products
Search
Document Center

Elastic Compute Service:Overview

Last Updated:Dec 11, 2024

Launch templates provide a way to templatize your requests to create Elastic Compute Service (ECS) instances. You can use a launch template to store ECS instance creation parameters, including the key pair, Resource Access Management (RAM) role, instance type, and network settings. The template does not include instance passwords. You can quickly create ECS instances from the launch template without the need to specify the ECS instance parameters. Each launch template can have multiple versions, and each version can have different parameters. You can use any version of a specific launch template to quickly create ECS instances. This topic describes the features, usage scenarios, limits, and billing of launch templates and the operations that can be performed on launch templates.

Features and benefits

All configurations in launch templates are optional, which offers greater elasticity and scalability in ECS instance creation and can better meet individual requirements in various scenarios. Launch templates provide the following features and benefits:

  • Preset parameters: You can preset ECS instance creation parameters, such as the instance type, operating system, hardware settings, network settings, security rules, and storage settings, in a launch template.

  • Standardization and consistency: You can use a launch template to create ECS instances that have identical configurations and host identical environments. This reduces the risk of human error in configuration and facilitates management and maintenance.

  • Quick deployment: You can quickly create ECS instances from a launch template without the need to specify instance parameters.

  • Version control and iteration: Launch templates provide version control capabilities, which allow you to create different versions of a launch template in order to iterate or optimize the launch template or suit different projects. You can change the configurations in a launch template and save the changed launch template as a new version.

    Launch template versions

    The following figure shows a launch template that has three versions. An instance type, an image, a vSwitch, and a virtual private cloud (VPC) are specified in Version 1. Version 2 is created based on Version 1 and specifies a security group in addition to the information specified in Version 1. The values of specific parameters in Version 3 are different from those in Version 1 and Version 2. Version 1 is the default version of the launch template. If you use this launch template to create ECS instances and do not specify a version, the instances are created by using the parameters defined in Version 1.

    image

Usage scenarios

  • New application deployment: To deploy a new application on instances, you can use a launch template to create the instances to ensure that the development, testing, and production environments for the application are consistent.

  • Auto scaling and disaster recovery: You can use launch templates to quickly replicate and configure ECS instances when you create scaling groups or disaster recovery plans.

  • Continuous integration/continuous deployment (CI/CD): You can integrate launch templates with the CI/CD process to enable rapid deployment of code to pre-configured environments.

  • Elastic use of resources:

    • Auto Scaling: You can use an existing launch template to quickly create a scaling group for ECS instances. Auto Scaling uses configurations defined in the launch template to create a scaling group. If specific configurations do not meet business requirements, you can modify the configurations on the Create Scaling Group page. For more information, see Create a scaling group based on an existing ECS instance.

    • Auto Provisioning: Auto provisioning groups use launch templates as instance configuration sources to create ECS instances that inherit the attributes of the launch templates, such as instance images, security groups, and logon credentials. After an auto provisioning group is created, the group provisions and starts an ECS instance cluster at the specified point in time. This improves the efficiency of provisioning a large number of ECS instances at a time. For more information, see Create an auto provisioning group.

Limits

  • Quotas: Each account can have up to 30 launch templates per region and up to 30 versions per launch template.

  • Optional parameters: When you create a launch template, all parameters are optional. However, if a launch template does not include required parameters such as the instance type and image, you must specify these parameters when you use the launch template to create ECS instances.

  • Immutability: Launch templates are immutable. To modify a launch template, you must create a new version of the launch template.

Billing

You are not charged for launch templates. However, you may be charged when you use launch templates to deploy ECS resources. For information about the billing of ECS resources, see Billing overview.

Tasks

Create a launch template

You can specify the configuration information that is used to create ECS instances in a launch template based on your business requirements, and then use the launch template to create ECS instances, scaling groups, or auto provisioning groups. This section describes how to create a launch template.

Use the ECS console

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Deployment & Elasticity > icon1 > Launch Templates.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. On the Launch Templates page, click Create Template.

  5. On the Launch Template page, specify parameters in the Basic Configurations (Optional) and Advanced Configurations (Optional) steps.

    You can specify parameters to create a launch template, or select an existing launch template to use as a basis to create a new launch template. For information about the parameters and how to configure them, see Create an instance on the Custom Launch tab.

    Note

    The first time you create a launch template, the Clone Template section is unavailable. If you have already created launch templates, you can select an existing launch template and a version of the launch template and then modify the parameters to create a new launch template.

    In the Instance Type section, you can quickly filter instance types on the Scenario-based Selection tab to find the instance types that meet your business requirements.

  6. In the Confirm Configurations step, enter a name for the launch template and a description for the launch template version. Then, click Create Launch Template.

    • Configurations: You can click the修改 icon in the Basic Configurations and Advanced Configurations sections to modify the parameters.

      Note

      The parameters in the Basic Configurations and Advanced Configurations sections are required to create ECS instances and simplify subsequent instance creation. However, these parameters are optional on the Launch Template page and can be configured as needed.

    • Save As: You can specify how to save the current configurations based on your business requirements.

      • Create Template: If you select Create Template in the Save As section, the current configurations are saved as the default version of a new launch template.

      • Create Version: You can select an existing template and save the current configurations as the latest version of the launch template.

    • Template Name and Version Description: You can enter a name for the launch template and a description for the launch template version to facilitate subsequent management.

    • Template Resource Group: You can select an existing resource group to assign the launch template to the resource group.

      If you want to create a new resource group, click here to go to the Create Resource Group page and create a resource group. For more information, see Resource groups.

    实例模板

  7. In the Success message, click View Template to view the launch template that you created in the ECS console.

Call an API operation

Call the CreateLaunchTemplate operation to create a launch template.

Use a launch template to create an ECS instance

You can use any version of a specific launch template to quickly create ECS instances. This improves user experience and the efficiency of instance creation. This section describes how to use a launch template to create an ECS instance.

Note

Before you use a launch template to create an ECS instance, make sure that you already created a launch template or a new version of an existing launch template.

Use the ECS console

  1. On the Launch Templates page, find the launch template that you want to use and click Create Instance in the Actions column.

    You can also select a launch template ID to view the configurations of the launch template and click Create Instance in the Actions column corresponding to a version. 新建版本

  2. On the Custom Launch tab, the selected launch template and version are automatically loaded. After the launch template and version are loaded, check all configurations.

    Note

    If you want to modify parameters or the selected template does not include specific required parameters, click the 编辑 icon to modify the configurations.

  3. Create an ECS instance.

    • To create a subscription ECS instance, configure the Duration parameter and select ECS Terms of Service and Product Terms of Service. Click Create Order.

    • To create a pay-as-you-go ECS instance, select ECS Terms of Service and Product Terms of Service. Click Create Instance.

    After the ECS instance is created, go to the Instance page in the ECS console to view the instance.

Call an API operation

You can also call the RunInstances operation and specify the LaunchTemplateId and LaunchTemplateVersion parameters to batch create ECS instances. This eliminates the need to specify a large number of parameters each time you create ECS instances. For more information, see RunInstances.

Manage the versions of a launch template

After you create a launch template, you cannot modify the launch template. You can create a new version of the launch template and modify the parameters of the launch template in the new version. When you create ECS instances from a launch template, you can use any version of the launch template. If you do not specify a version, the default version is used. This section describes how to create a new version of a launch template, set the most frequently used version as the default version, and delete a version that is no longer needed.

Create a new version of a launch template

Use the ECS console

  1. On the Launch Templates page, find a launch template for which you want to create a version and click New Version in the Actions column.

    Alternatively, click the ID of the launch template for which you want to create a version to view the configurations, and click New Version in the Version Information section.新建版本

  2. On the Launch Template page, configure parameters.

    In the Clone Template section, you can select an existing template and version to use as a basis and configure the parameters for the new version. For information about the parameters and how to configure them, see Create an instance on the Custom Launch tab.

  3. In the Confirm Configurations step, select Create Version and select the launch template for which you want to save the new version.

  4. Click Create Launch Template.

  5. In the message that appears, click View New Version to go to the ECS console and view the created version of the launch template.

    Note

    You can also view all created launch templates in the launch template list on the Launch Templates page.

Call an API operation

You can manage the versions of a launch template by calling the following API operation:

Change the default version of a launch template

You can set the most frequently used version of a launch template used as the default version of the launch template. If you do not specify a version when you use a launch template to create ECS instances, the default version of the launch template is automatically used to create ECS instances. This section describes how to change the default version of a launch template.

Use the ECS console

On the Launch Templates page, select the ID of the launch template whose default version you want to change. In the Version Information section, find the version that you want to set as the default version and click Set as Default in the Actions column.

默认版本

Call an API operation

You can manage the versions of a launch template by calling the following API operation:

ModifyLaunchTemplateDefaultVersion: specifies a version of a launch template as the default version of the launch template.

Delete a launch template version

You can perform the following operations to delete a launch template version that is no longer needed.

Important
  • You cannot delete the default version of a launch template. In this case, you can change the default version and then delete the non-default version. For more information about how to change the default version of a launch template, see Change the default version of a launch template.

  • If you no longer need all versions of a launch template, you need to only delete the launch template. For more information, see Delete a launch template.

Use the ECS console

  1. On the Launch Templates page, select the launch template that you want to manage to expand its version information.

  2. In the Version Information section, delete one or more versions.

    • To delete a single version, find the version and click Delete in the Actions column.

    • To batch delete versions, select the versions and click Delete above the Version column.

  3. In the Delete Version message, click OK.

Call an API operation

You can also delete a launch template version by calling the following API operation:

Delete a launch template

If you no longer need a launch template, you can delete the launch template. The deletion of a launch template does not affect the ECS instances that were created from the launch template. This section describes how to delete a launch template.

Important

If you delete a launch template, all versions of the launch template are deleted. Proceed with caution. You can delete a specific version of a launch template. For more information, see Delete a launch template version.

Use the ECS console

  1. On the Launch Templates page, delete one or more launch templates.

    • To delete a single launch template, find the launch template and click Delete in the Actions column.

    • To batch delete launch templates, select the launch templates and click Delete above the Template ID column.

  2. In the message that appears, click OK.

Call an API operation

You can call an API operation to delete a launch template. For more information, see DeleteLaunchTemplate.

References