I am trying to create an instance in ec2 using CLI.
Is there anyway to specify tags to the instance when using CLI to create instances?
aws ec2 run-instances --image-id $ami_id --key-name $deployment_key_name \
--region $region --security-groups default --instance-type m4.large \
--user-data file://./yaml/master.yaml
Best Answer
As of 28 March 2017, you can specify tags for instances (and attached volumes) as part of the
run-instances
command.Example:
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