How to give Name
in command line when running aws ec2 run-instances
?
I don't find it in the official docs
How to give Name
in command line when running aws ec2 run-instances
?
I don't find it in the official docs
The Name that's displayed there is taken from the Name tag. To set the instance name e.g. to test01
and its volume name to test01-disk1
you'd run something like this:
aws ec2 run-instances --tag-specifications \
'ResourceType=instance,Tags=[{Key=Name,Value=test01}]' \
'ResourceType=volume,Tags=[{Key=Name,Value=test01-disk1}]' \
... other parameters ...
Hope that helps :)
Install jq
aws ec2 create-tags --resources \
`aws ec2 run-instances --image-id ami-8f50120g --instance-type t2.small \
--subnet-id subnet-xxxxxxx --security-group-ids sg-xxxxxxxx --key-name "MyKey" \
| jq -r ".Instances[0].InstanceId"` \
--tags "Key=Name,Value=development"