Launch instances from a launch template
Launch templates are supported by several instance launch services. This topic describes how to use a launch template when launching an instance using the EC2 launch instance wizard, Amazon EC2 Auto Scaling, EC2 Fleet, and Spot Fleet.
Topics
Launch an instance from a launch template
You can use the parameters contained in a launch template to launch an instance. You have the option to override or add launch parameters before you launch the instance.
Instances that are launched using a launch template are automatically assigned two
tags with the keys aws:ec2launchtemplate:id
and
aws:ec2launchtemplate:version
. You cannot remove or edit these
tags.
Use launch templates with Amazon EC2 Auto Scaling
You can create an Auto Scaling group and specify a launch template to use for the group. When Amazon EC2 Auto Scaling launches instances in the Auto Scaling group, it uses the launch parameters defined in the associated launch template. For more information, see Creating an Auto Scaling Group Using a Launch Template in the Amazon EC2 Auto Scaling User Guide.
Before you can create an Auto Scaling group using a launch template, you must create a launch template that includes the parameters required to launch an instance in an Auto Scaling group, such as the ID of the AMI. The console provides guidance to help you create a template that you can use with Auto Scaling.
To create a launch template to use with Auto Scaling using the console
Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/
. -
In the navigation pane, choose Launch Templates, and then choose Create launch template.
-
For Launch template name, enter a descriptive name for the launch template.
-
For Template version description, provide a brief description of this version of the launch template.
-
Under Auto Scaling guidance, select the check box to have Amazon EC2 provide guidance to help create a template to use with Auto Scaling.
-
Modify the launch parameters as required. Because you selected Auto Scaling guidance, some fields are required and some fields are not available. For considerations to keep in mind when creating a launch template, and for information about how to configure the launch parameters for Auto Scaling, see Creating a launch template for an Auto Scaling group in the Amazon EC2 Auto Scaling User Guide.
-
Choose Create launch template.
-
(Optional) To create an Auto Scaling group using this launch template, on the Next steps page, choose Create Auto Scaling group.
To create or update an Amazon EC2 Auto Scaling group with a launch template using the Amazon CLI
-
Use the create-auto-scaling-group or the update-auto-scaling-group command and specify the
--launch-template
parameter.
Use launch templates with EC2 Fleet
You can create an EC2 Fleet request and specify a launch template in the instance configuration. When Amazon EC2 fulfills the EC2 Fleet request, it uses the launch parameters defined in the associated launch template. You can override some of the parameters that are specified in the launch template.
For more information, see Create an EC2 Fleet.
To create an EC2 Fleet with a launch template using the Amazon CLI
-
Use the create-fleet command. Use the
--launch-template-configs
parameter to specify the launch template and any overrides for the launch template.
Use launch templates with Spot Fleet
You can create a Spot Fleet request and specify a launch template in the instance configuration. When Amazon EC2 fulfills the Spot Fleet request, it uses the launch parameters defined in the associated launch template. You can override some of the parameters that are specified in the launch template.
For more information, see Create a Spot Fleet request.
To create a Spot Fleet request with a launch template using the console
-
Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/
. -
In the navigation pane, choose Spot Requests.
-
Choose Request Spot Instances.
-
Under Launch parameters, choose Use a launch template.
-
For Launch template, choose a launch template, and then, from the field to the right, choose the launch template version.
-
Configure your Spot Fleet by selecting different options on this screen. For more information about the options, see Create a Spot Fleet request using defined parameters (console).
-
When you're ready to create your Spot Fleet, choose Launch.
To create a Spot Fleet request with a launch template using the Amazon CLI
-
Use the request-spot-fleet command. Use the
LaunchTemplateConfigs
parameter to specify the launch template and any overrides for the launch template.