Copy Launch Configurations to Launch Templates
To migrate from launch configurations to launch templates, you must reproduce or recreate your release configurations as launch templates. We suggest that you migrate to launch templates to take benefit of the modern features of Amazon EC2 and Amazon EC2 Auto Scaling.
If you reproduce your launch configurations, you can migrate them unexpectedly, or you could carry out an incremental migration over the years by choosing which release designs to copy. The copying feature is to be had best from the console.
Copy a Release Configuration to a Launch Template (Console)
-
Select the Amazon EC2 console at AWS.
-
On the navigation pane, beneath Auto Scaling, choose Launch Configurations.
-
Select the release configuration you want to replicate and choose Copy to release template; copy selected. These units up a brand new release template with the same name and options because of your selected launch configuration.
-
For the New release template call, you could use the name of the launch configuration (the default) or enter a brand new ring. Launch template names ought to be particular.
-
(Optional) To create an Auto Scaling group using the new release template, pick Create an Auto Scaling organisation the usage of the brand new template.
-
Choose Copy.
Use the subsequent technique to recognise that you need to replicate all release configurations to launch templates.
To Replica all Launch Configurations to Release Templates (Console)
-
Select the Amazon EC2 console at Amazon EC2.
-
On the navigation pane, under Auto Scaling, pick Launch Configurations.
-
Choose Copy to release template, Copy all. This copies every release configuration in the contemporary Region to a brand new release template with equal calls and alternatives.
- Choose Copy.
Replace a Launch Configuration with a Launch Template
When you correct an Auto Scaling institution with an existing release configuration, you've chosen to replace the release configuration with a launch template.
After you update the release configuration for an Auto Scaling group, any new instances are launched using the brand new release template. Existing examples are not affected. To update the prevailing times, terminate them so that they are changed by using your Auto Scaling institution, or allow automatic scaling and replace earlier times with more modern times based on your termination rules.
To put back the launch configuration for an Auto Scaling institution (console)
-
Unfolded the Amazon EC2 Auto Scaling console at Amazon AutoScaling.
-
Choose the test field next in your Auto Scaling group.
-
A split-pane opens up within the bottom a part of the page, showing information about the organisation it indeed is selected.
-
On the Details tab, pick Launch configuration, Edit.
-
Choose Switch to release the template.
-
For the Launch template, choose your release template.
-
For Version, pick out the launch template version as wanted. After creating variations of a launch template, you can select whether the Auto Scaling institution uses the default or the modern-day version of the release template whilst scaling out.
-
When you have completed it, select Update.
To update a release configuration use the command line. You can use one of the following commands:
-
replace-auto-scaling-organization (AWS CLI)
- Update-ASAutoScalingGroup (AWS Tools for Windows PowerShell)
Request Spot Instances for Fault-Tolerant and Flexible Packages
When you create a release template to release only Spot Instances, preserve the subsequent concerns in mind:
-
Spot charge. You pay the current Spot price most effectively for the Spot Instances that you launch. This pricing changes slowly over the years based on lengthy-time period tendencies in supply and demand.
-
You were setting your best fee. You can optionally include a maximum fee in line with the hour for Spot Instances on your launch template. If your total cost exceeds the current Spot rate, the Amazon EC2 Spot service fulfils your request if capacity is to be had. If the rate for Spot Instances rises above your maximum charge for a walking example to your Auto Scaling institution, it terminates your instance.
-
They are balanced throughout Availability Zones. If you specify more than one Availability Zones, Amazon EC2 Auto Scaling distributes the Spot requests across the required zones. If your maximum fee is just too low in a single Availability Zone for any requests, Amazon EC2 Auto Scaling checks whether recommendations have been fulfilled in the different zones. If so, Amazon EC2 Auto Scaling cancels the failed requests and redistributes them throughout the Availability Zones that have requests fulfilled. If the rate in an Availability Zone without a fulfilled request drops enough that destiny requests are triumphant, Amazon EC2 Auto Scaling rebalances across all Availability Zones.
-
Spot Instance termination. Launching templates can terminate spot Instances at any time. The Amazon EC2 Spot carrier can remove Spot Instances to your Auto Scaling group because the accessibility of, or price for, Spot Instances changes. When scaling or appearing in health exams, Amazon EC2 Auto Scaling can similarly terminate Spot Instances that may end On-Demand Instances. When an instance is terminated, any storage is deleted.
-
It is maintaining your favoured capability. When a Spot Instance is closed, Amazon EC2 Auto Scaling attempts to release every other Spot Instance to preserve the favoured potential for the organisation. If the cutting-edge Spot rate is less than your price, it gets a Spot Instance. If the request for a Spot Instance is useless, it keeps attempting.
- You are changing your maximum fee. To exchange your full payment, create a news release template, replace a current launch template with the brand new most charge, and partner it with your Auto Scaling institution. The present Spot Instances hold to run as long as the most rate precise inside the release template used for those instances is better than the modern-day Spot rate. If you probably did now not set a maximum charge, the default maximum charge is the On-Demand charge.
Examples for developing and coping with release templates
You can make and control launch templates via the AWS Management Console, AWS CLI, or SDKs. This segment shows you examples of making and managing launch templates for Amazon EC2 Auto Scaling from the AWS CLI.
{
"LaunchTemplateName": "my-template-for-auto-scaling",
"VersionDescription": "test description",
"LaunchTemplateData": {
"ImageId": "ami-04d5cc9b88example",
"InstanceType": "t2.micro",
"SecurityGroupIds": [
"sg-903004f88example"
],
"KeyName": "MyKeyPair",
"Monitoring": {
"Enabled": true
},
"Placement": {
"Tenancy": "dedicated"
},
"CreditSpecification": {
"CpuCredits": "unlimited"
},
"MetadataOptions": {
"HttpTokens": "required",
"HttpPutResponseHopLimit": 1,
"HttpEndpoint": "enabled"
}
}
}
To create a primary release template
-
Put back the ami-04d5cc9b88 example with the ID of the AMI from which to release the times.
-
Replace t2. Micro with an example type is compatible with the AMI that you are precise.
This instance creates a release template with the call my-template-for-auto-scaling. If the samples created by this release template are released in a default VPC, they receive a public IP address by default. If the times are launched in a non default VPC, they no longer receive a public IP address by default.
Aws ec2 create-release-template --release-template-xyz my-template-for-vehicle-scaling --version-description version1
--release-template-data '"ImageId":"ami-04d5cc9b88example","InstanceType":"t2.Micro"'
Specify tags that tag instances at launch
aws ec2 create-launch-template --launch-template-xyz my-template-for-auto-scaling --version-description version1 \
--launch-template-data '{"TagSpecifications":[{"ResourceType":"instance","Tags":[{"Key":"purpose","Value":"webserver"}]}],"ImageId":"ami-04d5cc9b88example","InstanceType":"t2.micro"}'
Specify an IAM role to pass to instances
aws ec2 create-launch-template --launch-template-xyz my-template-for-auto-scaling --version-description version1 \
--launch-template-data '{"IamInstanceProfile":{"Xyz":"my-instance-profile"},"ImageId":"ami-04d5cc9b88example","InstanceType":"t2.micro"}'
Assign public IP addresses
aws ec2 create-launch-template --launch-template-xyz my-template-for-auto-scaling --version-description version1 \
--launch-template-data '{"NetworkInterfaces":[{"DeviceIndex":0,"AssociatePublicIpAddress":true,"Groups":["sg-903004f88example"],"DeleteOnTermination":true}],"ImageId":"ami-04d5cc9b88example","InstanceType":"t2.micro"}'
Specify a user data script that configures instances at launch
aws ec2 create-launch-template --launch-template-xyz my-template-for-auto-scaling --version-description version1 \
--launch-template-data '{"UserData":"IyEvYmluL2Jhc...","ImageId":"ami-04d5cc9b88example","InstanceType":"t2.micro"}'
Specify a block device mapping
aws ec2 create-launch-template --launch-template-xyz my-template-for-auto-scaling --version-description version1 \
--launch-template-data '{"BlockDeviceMappings":[{"DeviceXYZ":"/dev/xvdcz","Ebs":{"VolumeSize":22,"VolumeType":"gp2","DeleteOnTermination":true}}],"ImageId":"ami-04d5cc9b88example","InstanceType":"t2.micro"}'
Specify Dedicated Hosts to bring software licenses from external vendors
aws ec2 create-launch-template --launch-template-xyz my-template-for-auto-scaling --version-description version1 \
--launch-template-data '{"Placement":{"Tenancy":"host","HostResourceGroupArn":"arn"},"LicenseSpecifications":[{"LicenseConfigurationArn":"arn"}],"ImageId":"ami-04d5cc9b88example","InstanceType":"t2.micro"}'
Specify an existing network interface
aws ec2 create-launch-template --launch-template-xyz my-template-for-auto-scaling --version-description version1 \
--launch-template-data '{"NetworkInterfaces":[{"DeviceIndex":0,"NetworkInterfaceId":"eni-b9a5ac93","DeleteOnTermination":false}],"ImageId":"ami-04d5cc9b88example","InstanceType":"t2.micro"}'
Create multiple network interfaces
aws ec2 create-launch-template --launch-template-xyz my-template-for-auto-scaling --version-description version1 \
--launch-template-data '{"NetworkInterfaces":[{"DeviceIndex":0,"Groups":["sg-903004f88example"],"DeleteOnTermination":true},{"DeviceIndex":1,"Groups":["sg-903004f88example"],"DeleteOnTermination":true}],"ImageId":"ami-04d5cc9b88example","InstanceType":"t2.micro"}'
Manage your launch templates
The AWS CLI consists of numerous other commands that assist you in manipulating your launch templates.
List and describe your launch templates.
You can use two AWS CLI instructions to get your release templates statistics: describe-release-templates and describe-release-template-variations.
The following example provides a precis of the specified release template.
aws ec2 describe-launch-templates --launch-template-names my-template-for-auto-scaling
The following describe-release-template-versions command presents data describing the variations of the required launch template my-template-for-auto-scaling.
aws ec2 describe-launch-template-versions --launch-template-id lt-068f72b729example
Create a launch template version
aws ec2 create-launch-template-version --launch-template-id lt-068f72b729example --version-description version2 \
--source-version 1 --launch-template-data "ImageId=ami-c998b6b2example"
Delete a launch template version
aws ec2 delete-launch-template-versions --launch-template-id lt-068f72b729example --versions 1
Delete a launch template
aws ec2 delete-launch-template --launch-template-id lt-068f72b729example
Frequently Asked Questions
What is the distinction between release template and release configuration in AWS?
Release configurations are used with Auto Scaling Groups. While release templates are used whilst you release an example the use of the AWS EC2 console, an AWS SDK, or a command-line device. Launch templates allow you to save the parameters (AMI, instance type, security corporations, key pairs and so forth.)
What gain does a release template have over a launch configuration?
However, defining a launch template rather than a launch configuration lets you have a couple of variations of a launch template. With versioning of release templates, you could create a subset of the entire set of parameters. Then, you may reuse it to create different variations of the equal release template.
Can you regulate a release template?
Modifies a release template. You can specify which version of the release template to set as the default version. When launching an example, the default model applies while a release template model is not specified.
What are AWS launch templates?
A release template is an Amazon Elastic Compute Cloud (EC2) feature that reduces the number of steps which might be required to create an AWS example via capturing all launch parameters inside one useful resource.
Conclusion
This blog extensively discussed the concept of Launching Templates in AWS EC2 Auto Scaling and one of the Launching Templates in AWS EC2 Auto Scaling offered by AWS EC2. We mentioned the significance of making and converting the configuration in AWS in detail with the assistance of an instance application.
Refer to our Guided Path on Coding Ninjas Studio to upskill yourself in Data Structures and Algorithms, Competitive Programming, JavaScript, System Design, and many more! If you want to test your competency in coding, you may check out the mock test series and participate in the contests hosted on Coding Ninjas Studio! But if you have just started your learning process and are looking for questions asked by tech giants like Amazon, Microsoft, Uber, etc; you must look at the problems, interview experiences, and interview bundle for placement preparations.
Nevertheless, you may consider our paid courses to give your career an edge over others!
Do upvote our blogs if you find them helpful and engaging!
Happy Learning!