-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgetMetadata.sh
26 lines (26 loc) · 908 Bytes
/
getMetadata.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
# NO PRODUCTION SAFE WARRANTY!!
# Using GET to retrieve all meta data on EC2 instance.
digger () {
PADDRESS=$1;
for ENTRY in `GET $PADDRESS`;
do
LEN=$((${#ENTRY}-1));
LC=${ENTRY:$LEN:1};
if [ $LC == "/" ]; then # Container
NEWPADDRESS=$PADDRESS$ENTRY;
digger $NEWPADDRESS
else # Leaf
T=`echo $ENTRY | grep "0="`;
if [ ! -z $T ]; then
ENTRY="0/openssh-key";
fi;
LEAF="$PADDRESS$ENTRY";
CNAME=`echo $LEAF | sed -e 's/^.\{39\}//'`
echo "$CNAME: `GET $LEAF`";
fi;
done;
echo
PADDRESS=`echo $PADDRESS | sed -e 's/\/[^/]*\/$/\//g'`
}
digger http://169.254.169.254/latest/meta-data/