Skip to content

Instantly share code, notes, and snippets.

@pcn
Last active August 31, 2015 16:45
Show Gist options
  • Select an option

  • Save pcn/ac27a07a2cc725bb8f26 to your computer and use it in GitHub Desktop.

Select an option

Save pcn/ac27a07a2cc725bb8f26 to your computer and use it in GitHub Desktop.
Using jq and the instance-id of an AWS node to get its name tag

You can get the instance-id of a system via curl, so something like this is an all-in-one:

ubuntu@test-aws-box$ aws ec2  describe-instances \
  --instance-id $(curl -s http://169.254.169.254/latest/meta-data/instance-id) | \
  jq '.Reservations[0].Instances[0].Tags[] | select(.Key == "Name").Value '
"the-name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment