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.
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
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
On the Launch Templates page, click Create Template.
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.
NoteThe 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.
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.
NoteThe 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.
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.
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
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.
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.
NoteIf you want to modify parameters or the selected template does not include specific required parameters, click the icon to modify the configurations.
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
Change the default version of a launch template
Delete a launch template version
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.
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
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.
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
DescribeLaunchTemplates: queries available launch templates.
DescribeLaunchTemplateVersions: queries the versions of a launch template.
Provisioning methods of ECS instances: describes the methods that you can use to batch create ECS instances.