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?
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.
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.
AutoScaling has two components: Launch Configurations and Auto Scaling Groups. Launch Configurations hold the instructions for the creation of new instances.
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.
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.
Launch Configuration(Legacy): Must be recreated every time because modification is not allowed.
Launch Template (Recommended By AWS) :
I hope the above answer clarifies the doubt.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With