Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between AWS ASG Launch Templates and Launch Configurations?

I'm getting confused when using Terraform to provision an auto-scaling group. Should I use launch configuration or launch template for EC2 properties, such as which AMI, instance types, ...?

I don't know what the difference is between them, which we should use and why they exist?

like image 471
Dat Ho Avatar asked May 24 '20 04:05

Dat Ho


People also ask

What is the difference between launch template and launch configuration?

However, defining a launch template instead of a launch configuration allows you to have multiple versions of a launch template. With versioning of launch templates, you can create a subset of the full set of parameters. Then, you can reuse it to create other versions of the same launch template.

What is the purpose of launch template?

A launch template contains the configuration information to launch an instance so that you do not have to specify them each time you launch an instance. For example, a launch template can contain the AMI ID, instance type, and network settings that you typically use to launch instances.

What are the two main components of AWS Auto Scaling?

AutoScaling has two components: Launch Configurations and Auto Scaling Groups. Launch Configurations hold the instructions for the creation of new instances.

What is the difference between template and AMI in AWS?

An Amazon Machine Image (AMI) is a template that contains a software configuration (for example, an operating system, an application server, and applications). From an AMI, you launch an instance, which is a copy of the AMI running as a virtual server in the cloud.


2 Answers

Launch templates (LTs) are newer than launch configurations (LCs) and provide more options to work with. Thus, the AWS documentation recommends use of launch templates (LTs) over launch configuration (LCs):

We recommend that you create Auto Scaling groups from launch templates to ensure that you're getting the latest features from Amazon EC2.

One of the practical key differences between LT and LC is the fact that LC is immutable. Once you define it, you can't edit it. Only a replacement is an option. However, a single LT can have multiple versions:

defining a launch template instead of a launch configuration allows you to have multiple versions of a template. With versioning, you can create a subset of the full set of parameters and then reuse it to create other templates or template versions.

Also LTs provide more EC2 options for you to configure, for example, dedicated hosting can be set only using a LT. Similarly, ability to use T2 unlimited burst credit option is only available in a LT.

Thus if you can, its better to follow AWS recommendation and use LT.

like image 100
Marcin Avatar answered Oct 05 '22 12:10

Marcin



Both are used in instance creation in ASG.


Launch Configuration(Legacy): Must be recreated every time because modification is not allowed.

Launch Template (Recommended By AWS) :

  1. Allows to edit and update.
  2. Maintains versions.
  3. Can use T2 unlimited burst feature.
  4. Allow provisioning using both On-demand and Spot Instances.
  5. Creation of parameter subsets.(Partial configuration for reuse and inheritance)
  6. Can also be used to launch a standalone instance using AWS Console, SDK and CLI.

I hope the above answer clarifies the doubt.

like image 30
vijayraj34 Avatar answered Oct 05 '22 12:10

vijayraj34