Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion ec2-metadata
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ Options:
-r/--ramdisk-id The ID of the RAM disk launched with this instance, if applicable.
-e/--reservation-id ID of the reservation.
-s/--security-groups Names of the security groups the instance is launched in. Only available if supplied at instance launch time
-d/--user-data User-supplied data.Only available if supplied at instance launch time."
-d/--user-data User-supplied data.Only available if supplied at instance launch time.
-g/--tags Tags assigned to this instance."
}

METADATA_BASEURL="http://169.254.169.254"
Expand Down Expand Up @@ -108,6 +109,20 @@ function print_public-keys()
fi
}

#print tags
function print_tags()
{
echo 'tags: '
x=$(get_meta meta-data/tags/instance/)
if [ -n "${x}" ]; then
for i in $x; do
echo -e '\t' $i: $(get_meta meta-data/tags/instance/$i)
done
else
echo not available
fi
}

function print_all()
{
print_normal_metric ami-id meta-data/ami-id
Expand All @@ -129,6 +144,7 @@ function print_all()
print_normal_metric reservation-id /meta-data/reservation-id
print_normal_metric security-groups meta-data/security-groups
print_normal_metric user-data user-data
print_tags
}

#check if run inside an EC2 instance
Expand Down Expand Up @@ -180,6 +196,8 @@ while [ "$1" != "" ]; do
;;
-d | --user-data ) print_normal_metric user-data user-data
;;
-g | --tags ) print_tags
;;
-h | --help ) print_help
exit
;;
Expand Down