
This assumes you have already configured the aws command line tool. If not, check out my article on Getting Started with the AWS CLI.
An EC2 Launch Template is a way to set certain defaults for launching a new EC2 instance, such as the SSH Key Pairs, Network Subnets, Security Groups, Amazon Machine Image, et cetera that the EC2 Instance will have. An EC2 Launch Template is often used with an EC2 Auto Scaling Group, to auto scale a collection of EC2 instances based on needs, such as when load is high or low is low.
The aws ec2 describe-launch-templates command can be used to list your Launch Templates.
~]# aws ec2 describe-launch-templates
{
"LaunchTemplates": [
{
"LatestVersionNumber": 1,
"LaunchTemplateId": "lt-0dfee84b8657928cb",
"LaunchTemplateName": "my-launch-template",
"DefaultVersionNumber": 1,
"CreatedBy": "arn:aws:iam::123456789012:user/johndoe",
"CreateTime": "2024-02-06T02:43:24.000Z"
},
{
"LatestVersionNumber": 1,
"LaunchTemplateId": "lt-02a69fb580b1a050d",
"LaunchTemplateName": "my-launch-template-with-key",
"DefaultVersionNumber": 1,
"CreatedBy": "arn:aws:iam::123456789012:user/johndoe",
"CreateTime": "2024-02-07T02:25:51.000Z"
}
]
}
And then the aws ec2 delete-launch-template command can be used to delete a Launch Template. In this example, the --launch-template-id option is used.
aws ec2 delete-launch-template --launch-template-id lt-0dfee84b8657928cb
In this example, the --launch-template-name option is used.
aws ec2 delete-launch-template --launch-template-name my-launch-template-with-key
Did you find this article helpful?
If so, consider buying me a coffee over at