Launch EC2 instances using a launch template
An Amazon EC2 launch template stores instance launch parameters so that you don't have to specify them every time you launch an instance.
Several instance launch services can optionally use launch templates when launching instances, while for other services, like EC2 Fleet, instances can't be launched unless a launch template is used. 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.
For more information about launch templates, including how to create a launch template, see Store instance launch parameters in Amazon EC2 launch templates.
Topics
Launch an Amazon EC2 instance using a launch template
You can use the parameters contained in a launch template to launch an Amazon EC2 instance. After selecting the launch template, but before launching the instance, you can modify the launch parameters.
Instances that are launched using a launch template are automatically assigned two
tags with the keys aws:ec2launchtemplate:id
and
aws:ec2launchtemplate:version
. You can't remove or edit these
tags.
Launch instances in an Amazon EC2 Auto Scaling group using a launch template
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.
Before you can create an Auto Scaling group using a launch template, you must first create a launch template that includes the parameters required to launch an instance in an Auto Scaling group. Some parameters are required, such as the ID of the AMI, and some parameters are not available to use with an Auto Scaling group. The console provides guidance to help you create a template that you can use with Amazon EC2 Auto Scaling.
To create an Auto Scaling group with a launch template using the console
-
For the instructions, see Create an Auto Scaling group using a launch template in the Amazon EC2 Auto Scaling User Guide.
To create or update an Auto Scaling group with a launch template using the AWS CLI
-
Use the create-auto-scaling-group or the update-auto-scaling-group command and specify the
--launch-template
parameter.
For more information, see the following topics in the Amazon EC2 Auto Scaling User Guide:
-
Examples for creating and managing launch templates with the AWS Command Line Interface (AWS CLI) – Provides examples that show how to create launch templates with various parameter combinations.
Launch an EC2 Fleet using a launch template
A launch template is a requirement when creating an EC2 Fleet request. 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 AWS CLI
-
Use the create-fleet command. Use the
--launch-template-configs
parameter to specify the launch template and any overrides for the launch template.
Launch a Spot Fleet using a launch template
A launch template is optional when creating a Spot Fleet request. If you don't use a launch template, you can manually specify the launch parameters. If you use a launch template, 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.
To create a Spot Fleet request using a launch template
Open the Amazon EC2 console at https://console.aws.amazon.com/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 using a launch template
-
Use the request-spot-fleet command. Use the
LaunchTemplateConfigs
parameter to specify the launch template and any overrides for the launch template.