How to add a Tag when launching an ec2 instance using aws clis
As of 28 March 2017, you can specify tags for instances (and attached volumes) as part of the run-instances
command.
Example:
aws ec2 run-instances --image-id ami-abc12345 --count 1 \
--instance-type t2.micro --key-name MyKeyPair \
--subnet-id subnet-6e7f829e \
--tag-specifications 'ResourceType=instance,Tags=[{Key=webserver,Value=production}]' 'ResourceType=volume,Tags=[{Key=cost-center,Value=cc123}]'
Announcement blog post: https://aws.amazon.com/blogs/aws/new-tag-ec2-instances-ebs-volumes-on-creation/
Additional documentation (see example 4): http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Tags.html#Using_Tags_CLI