Is there a way to set an AWS instance's name from command line tools?

Solution 1:

Yes, you can use the command line tools to view this information, if you need to parse this information out, you will be better off using the API (as it is both far faster and the information is much easier to work with).

From the command line tools, run: ec2-describe-instances

You will find a line that reads similar to the following:

TAG     instance        i-xxxxxxxx      Name    MyTagName

For a cleaner readout, you might want to pipe the output through grep:

ec2-describe-instances | grep TAG

Don't forget to export (EC2_PRIVATE_KEY, EC2_CERT) or set (-K, -C) the path to your private key and certificate files.

Solution 2:

You can set the Name of an instance using the command line tools with this command

ec2addtag i-??????? --tag Name=my-fancy-name

Solution 3:

You can use the aws command to set the name of an instance like so:

aws ec2 create-tags --resources i-??????? --tag Key=Name,Value="MY INSTANCE NAME"

Solution 4:

Also note that there are other ways to get data about an instance from an instance:

/usr/bin/curl –s http://169.254.169.254/latest/meta-data/

http://www.newvem.com/get-aws-instance-metadata/