Skip to content

Instantly share code, notes, and snippets.

@kei-p
Last active October 13, 2015 00:48
Show Gist options
  • Save kei-p/e7cce87aaf404caef3d4 to your computer and use it in GitHub Desktop.
Save kei-p/e7cce87aaf404caef3d4 to your computer and use it in GitHub Desktop.
fetch_ec2_instance_name
## get instance_id
instance_id=$(curl http://169.254.169.254/latest/meta-data/instance-id)
## get Name Tag
instance_name=$(aws ec2 describe-instances --instance-ids ${instance_id} \
--query 'Reservations[*].Instances[*].Tags[?Key==`Name`].Value' \
--output text)
echo $instance_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment