File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ Options:
3737-r/--ramdisk-id The ID of the RAM disk launched with this instance, if applicable.
3838-e/--reservation-id ID of the reservation.
3939-s/--security-groups Names of the security groups the instance is launched in. Only available if supplied at instance launch time
40- -d/--user-data User-supplied data.Only available if supplied at instance launch time."
40+ -d/--user-data User-supplied data.Only available if supplied at instance launch time.
41+ -g/--tags Tags assigned to this instance."
4142}
4243
4344METADATA_BASEURL=" http://169.254.169.254"
@@ -108,6 +109,20 @@ function print_public-keys()
108109 fi
109110}
110111
112+ # print tags
113+ function print_tags()
114+ {
115+ echo ' tags: '
116+ x=$( get_meta meta-data/tags/instance/)
117+ if [ -n " ${x} " ]; then
118+ for i in $x ; do
119+ echo -e ' \t' $i : $( get_meta meta-data/tags/instance/$i )
120+ done
121+ else
122+ echo not available
123+ fi
124+ }
125+
111126function print_all()
112127{
113128 print_normal_metric ami-id meta-data/ami-id
@@ -129,6 +144,7 @@ function print_all()
129144 print_normal_metric reservation-id /meta-data/reservation-id
130145 print_normal_metric security-groups meta-data/security-groups
131146 print_normal_metric user-data user-data
147+ print_tags
132148}
133149
134150# check if run inside an EC2 instance
@@ -180,6 +196,8 @@ while [ "$1" != "" ]; do
180196 ;;
181197 -d | --user-data ) print_normal_metric user-data user-data
182198 ;;
199+ -g | --tags ) print_tags
200+ ;;
183201 -h | --help ) print_help
184202 exit
185203 ;;
You can’t perform that action at this time.
0 commit comments