Last active
October 13, 2015 00:48
-
-
Save kei-p/e7cce87aaf404caef3d4 to your computer and use it in GitHub Desktop.
fetch_ec2_instance_name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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