How to tag launch template _itself_ in AWS with JSON and `create-launch-template` AWS CLI

While creating EC2 launch templates with the create-launch-template AWS CLI ec2 command and a JSON spec, I can't seem to figure out how to tag the template itself. I'm providing the TagSpecifications correctly, because I can see the tags being applied to the resources when the launch template is used, but I want to tag the template itself, too.

I tried adding a Tags field to the JSON description of the launch template, that gave an error. The docs suggest using a TagSpecification object like so:

{
  "ResourceType": "launch-template",
  "Tags": [
    {
      "Key": "mykey", 
      "Value": "myvalue"
    }
  ]
}

... (note the "launch-template" resource type) which runs just fine without erring, but the template gets created without any tags :-/

I could run some follow-up tagging statements, but I'm trying to avoid doing that, and this article suggests it's doable at creation-time.


I have followed the AWS-CLI example from Creating a launch template and it was indeed created with the tag associated.

This is the command I used:

aws ec2 create-launch-template \
    --launch-template-name TemplateForWebServer \
    --version-description WebVersion1 \
    --tag-specifications 'ResourceType=launch-template,Tags=[{Key=purpose,Value=production}]' \
    --launch-template-data file://template-data.json

And this is the created launch template:

enter image description here

What's your AWS-CLI version? Perhaps it's too old. Mine is:

~ $ aws --version
aws-cli/1.18.97 Python/3.6.9 Linux/5.4.0-52-generic botocore/1.17.20