0
0
AWScloud~10 mins

Launch templates in AWS - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Launch templates
Create Launch Template
Define Configurations
Save Template Version
Launch EC2 Instance Using Template
Instance Runs with Template Settings
Optionally Create New Template Version
Repeat Launch with Updated Configurations
The flow shows creating a launch template, defining settings, saving it, launching instances from it, and optionally updating the template for future launches.
Execution Sample
AWS
aws ec2 create-launch-template --launch-template-name MyTemplate --version-description v1 --launch-template-data '{"ImageId":"ami-12345678","InstanceType":"t2.micro"}'
aws ec2 run-instances --launch-template LaunchTemplateName=MyTemplate,Version=1
This code creates a launch template with an AMI and instance type, then launches an EC2 instance using that template.
Process Table
StepActionInput/ConditionResult/Output
1Create launch templateName=MyTemplate, Version=v1, Data={ImageId=ami-12345678, InstanceType=t2.micro}Launch template MyTemplate version 1 created
2Launch instanceUse LaunchTemplateName=MyTemplate, Version=1EC2 instance launched with AMI ami-12345678 and type t2.micro
3Instance stateInstance initializingInstance state: pending
4Instance stateInstance bootingInstance state: running
5Optional: create new versionUpdate InstanceType to t3.microLaunch template MyTemplate version 2 created
6Launch instanceUse LaunchTemplateName=MyTemplate, Version=2EC2 instance launched with AMI ami-12345678 and type t3.micro
7EndNo more launchesExecution stops
💡 No more instances to launch, process ends
Status Tracker
VariableStartAfter Step 1After Step 5Final
LaunchTemplateNameNoneMyTemplateMyTemplateMyTemplate
VersionNone122
ImageIdNoneami-12345678ami-12345678ami-12345678
InstanceTypeNonet2.microt3.microt3.micro
InstanceStateNoneNonerunningrunning
Key Moments - 3 Insights
Why do we need to specify a version when launching an instance?
Each launch template version can have different settings. Specifying the version ensures the instance uses the correct configuration, as shown in execution_table steps 2 and 6.
Can we update a launch template directly without creating a new version?
No, launch templates are immutable. To change settings, you create a new version (step 5), preserving previous versions for reuse.
What happens if we launch an instance without specifying a version?
AWS uses the default version of the launch template. This is not shown in the table but is important to know to avoid unexpected configurations.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the InstanceType used at step 6?
At2.micro
Bt3.micro
Cami-12345678
Dpending
💡 Hint
Check the 'Result/Output' column at step 6 for the instance type.
At which step is a new launch template version created?
AStep 3
BStep 2
CStep 5
DStep 7
💡 Hint
Look for 'Launch template MyTemplate version 2 created' in the Result/Output column.
If we did not specify a version when launching an instance, what would happen?
AAWS uses the default launch template version
BAWS creates a new launch template version automatically
CThe instance launch would fail
DThe instance uses the latest version always
💡 Hint
Refer to key_moments explanation about default version usage.
Concept Snapshot
Launch templates store EC2 instance settings as reusable versions.
Create a template with configurations like AMI and instance type.
Launch instances by specifying template name and version.
Update settings by creating new versions, preserving old ones.
Using versions ensures consistent and repeatable instance launches.
Full Transcript
Launch templates in AWS let you save EC2 instance settings in a reusable way. First, you create a launch template with a name and version, defining details like the AMI and instance type. Then, you launch EC2 instances by referring to the template name and version. The instance starts with the saved settings. If you want to change settings, you create a new version of the launch template. This way, you keep old versions intact and can launch instances with different configurations as needed. Always specify the version when launching to control which settings are used. If you don't specify, AWS uses the default version. This process helps manage EC2 launches easily and consistently.