A launch template is a tool that helps you quickly create instances. It contains configurations for creating an ECS instance, such as a key pair, RAM role, instance type, and network settings, but excludes the instance password. Each template can have multiple versions, and each version can have different parameter settings. You can use any version of a specified template to quickly create an instance, which improves efficiency and user experience. This topic describes how to create an ECS instance using a launch template.
Prerequisites
-
You have created a launch template or a new version of an existing launch template. For more information, see Create a launch template and Manage launch template versions.
-
When you create pay-as-you-go ECS instances, the total value of your Alibaba Cloud account balance (cash balance) and coupons must be at least CNY 100.00. For more information, see Top up your account.
Procedure
Console
-
On the Launch Templates page, find the template that you want to use and click Create Instance in the Actions column.
Alternatively, click the template ID to open its details page. In the Version Information section, find the version that you want to use and click Create Instance in the Actions column.
-
On the Custom Launch page, select a template and version. After the configurations load, review all settings.
NoteIf you need to modify any parameters, or if the selected template is missing required parameters, click the
icon to edit the configuration. -
Click Confirm Order. In the Compare Configurations dialog box, review the original template configuration and the current configuration. After confirming the settings are correct, click Confirm and Create Order to create the instance.
After the instance is created, you can go to the Instance page in the ECS console to view the new instance.
API
You can also call API operations to create an instance from a launch template. The general steps are as follows:
-
Prepare the launch template that you want to use and determine its ID and version number. You can use one of the following methods:
-
Create a launch template: Call the CreateLaunchTemplate operation to create a launch template. Obtain the launch template ID
LaunchTemplateIdand the template version numberLaunchTemplateVersionNumberfrom the response. -
Query available launch templates: Call the DescribeLaunchTemplates operation to query available launch templates. From the response, find the
LaunchTemplateIdof the desired template. Then, call the DescribeLaunchTemplateVersions operation to view detailed version information and identify the template IDLaunchTemplateIdand version numberVersionNumberto use.
NoteA version of a launch template contains the configurations for creating an instance, such as the region, image ID, instance type, security group ID, and public bandwidth. If a specific configuration, such as the security group ID
SecurityGroupId, is not specified in the version, you must specify it when you create the instance. -
-
Create an instance from the launch template.
Call the RunInstances operation to create an instance. In the request, specify the launch template ID in the
LaunchTemplateIdparameter and the template version in theLaunchTemplateVersionparameter.Note that if a configuration is not specified in the launch template version, you must specify it when you create the instance. You can use this feature to separate fixed and variable parameters, making your launch templates more flexible.