Overview of launch templates

更新时间:
复制 MD 格式

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 a launch template are optional. This design provides greater flexibility and scalability for various scenarios.

  • 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: When you create a scaling group based on an ECS instance, you can use an existing launch template for quick setup. The system extracts configurations from the launch template to create the new scaling group. If some configurations do not meet your business requirements, you can modify them on the Create Scaling Group page. For more information, see Create a scaling group from an 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 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. Go to ECS Console - Launch Templates.

  2. In the upper-left corner of the page, select a region and resource group.地域

  3. Click Create Template.

  4. On the Template Name page, complete the basic and advanced configurations.

    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

    If you are creating a launch template for the first time, the Clone Template section is unavailable. If you have already created a launch template, you can select an existing template and version and modify its configuration.

    When you configure the Instance Type, you can use Scenario-based Selection to quickly find and select an instance type that meets your business needs.

  5. On the Confirm Configurations page, enter a template name and version description, and then click Create Launch Template.

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

      Note

      In the Basic Configurations and Advanced Configurations sections, we recommend that you configure all necessary parameters for instance creation to simplify future launches. However, all parameters are optional and can be configured as needed.

    • Save As: Select how to save the new template.

      • Create Template: Creates a new launch template and saves the current configuration as its default version.

      • Create Version: Requires you to select an existing launch template. The current configuration is saved as the latest version of that template.

    • Template Name and Version Description: Enter a name for the template and a description for the version to facilitate future management.

    • Template Resource Group: Select an existing resource group to organize your templates.

      To create a new resource group, click Create to go to the Resource Group page. For more information, see Resource groups.

    确认配置

  6. In the Created. dialog box, click View Template to view the created template in the 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 Template Name page, find the target template and click Create Instance in the Actions column.

    Alternatively, you can click a template ID to view its configuration details, and then click Create Instance in the Operation column for a specific version.新建版本

  2. On the Custom Launch page, select a template and version. After the configuration is loaded, review all settings.

    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.

    • If you selected a subscription instance, select a subscription duration, agree to the terms of service, and then click Confirm Order.

    • If you selected a pay-as-you-go instance, agree to the terms of service and then click Create Instance.

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

Call an API operation

You can also call the RunInstances operation and specify the LaunchTemplateId and LaunchTemplateVersion parameters to create ECS instances in batches. This eliminates the need to enter a large number of configuration parameters every time you create an instance. 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

Use the ECS console

  1. In the Actions column of the target template, click New Version.

    Alternatively, click a template ID to view its configuration details and click New Version in the Version Information section.新建版本

  2. On the Template Name page, customize the configuration parameters.

    In the Clone Template section, you can select an existing template and version to use as a base and then configure its parameters. For more information about the parameters, see Create an instance by using the wizard.

  3. On the Confirm Configurations page, select Create Version and choose the template to which you want to save the new version.

  4. Click Create Launch Template.

  5. In the dialog box that appears, click View New Version to go to the console and view the new version.

    Note

    You can also view all created templates in the template list on the Template Name 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 Template Name page, click a template ID to view its configuration details, and then click Set as Default in the Actions column for the desired version.

默认版本

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 Template Name page, click the target template ID to expand its version information.

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

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

    • To delete multiple versions at a time, select the versions that you want to delete and click Delete above the Version column.

  3. In the dialog box that appears, 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 Template Name page, delete one or more launch templates.

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

    • To delete multiple templates at a time, select the templates that you want to delete and click Delete above the Template ID column.

  2. In the dialog box 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