A launch template is a tool used to quickly create Elastic Compute Service (ECS) instances. The template contains all configurations (excluding passwords) that are used to create ECS instances. The configurations include the key pair, Resource Access Management (RAM) role, instance type, and network settings. Each template can have multiple versions, and different parameters can be configured in each version. You can use any version of a specific template to quickly create instances. This improves efficiency and user experience. This topic describes how to use a launch template to create an ECS instance.
Prerequisites
A launch template or a new version of an existing launch template is created. For more information, see Create an instance launch template and Manage launch template versions.
Bind your credit card or PayPal account. For more information ,see Introduction to AlibabaCloud Payment.
(Optional) If you want to purchase an ECS instance within the Chinese mainland, you must complete real-name verification. For more information, see How do I complete real-name verification?
Procedure
Create an instance in the ECS console
Log on to the ECS console.
In the left-side navigation pane, choose .
On the Launch Templates page, find the template that you want to use and click Create Instance in the Actions column.
You can also select a template ID to view the configurations of the template and click Create Instance in the Actions column.
On the Custom Launch tab, select the template and version. Check all configurations after they are loaded.
NoteIf you want to modify parameters or the selected template does not include the required parameters, click the icon to modify the configurations.
Create an ECS instance.
To create a subscription instance, configure the Duration parameter and select ECS Terms of Service and Product Terms of Service. Click Create Order.
If you select a pay-as-you-go instance, select ECS Terms of Service and Product Terms of Service and click Create Instance.
After the instance is created, go to the Instance page in the ECS console to view the instance.
Create an instance by calling API operations
To call API operations to create an ECS instance, perform the following steps:
Prepare a launch template and obtain the ID and version number of the launch template. You can use one of the following methods:
Create a launch template. You can call the CreateLaunchTemplate operation to create a launch template and obtain the ID (
LaunchTemplateId
) and version number (LaunchTemplateVersionNumber
) of the launch template from the response.Query available launch templates. You can call the DescribeLaunchTemplates operation to query the IDs of available launch templates (
LaunchTemplateId
). Then, call the DescribeLaunchTemplateVersions operation and specify the ID of a launch template in the request to query details about launch template versions. You can obtain the ID (LaunchTemplateId
) and version number (VersionNumber
) of the launch template that you want to use from the response.
NoteA launch template version includes parameters used to create an instance, such as the region ID, image ID, instance type, IDs of security groups, and public bandwidth. If a parameter, such as the
SecurityGroupId
parameter, is not included in the launch template version, you can specify the parameter when you create the instance.Create an instance based on the launch template.
Call the RunInstances operation to create an instance. When you call the operation, use the
LaunchTemplateId
andLaunchTemplateVersion
parameters to specify the launch template that you want to use.Take note that if a parameter is not included in the launch template, you can specify the parameter when you create the instance. To improve the flexibility of instance creation, you can evaluate instance parameters and determine which parameters can be configured in a launch template.