-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata-helper.sh
executable file
·91 lines (90 loc) · 4.32 KB
/
metadata-helper.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
#######################################################
# installs metadata helper tool
######################################################
var=bye,bye
file="/usr/bin/ec2-metadata"
if [ -f $file ]; then
echo "file is there"
else
echo "file in not there, installing file"
wget http://s3.amazonaws.com/ec2metadata/ec2-metadata
chmod u+x ec2-metadata
mv ec2-metadata /usr/bin/
fi
#####################################################
# Menu to get metadata
#####################################################
clear
echo "--------------------------------"
echo "Menu for AWS metadat helper tool"
echo "--------------------------------"
echo "0.Show all metadata information for this host (also default)."
echo "1.The AMI ID used to launch this instance"
echo "2.The index of this instance in the reservation (per AMI)"
echo "3.The manifest path of the AMI with which the instance was launched."
echo "4.The AMI IDs of any instances that were rebundled to create this AMI."
echo "5.Defines native device names to use when exposing virtual devices."
echo "6.The ID of this instance"
echo "7.The type of instance to launch. For more information, see Instance Types"
echo "8.The local hostname of the instance"
echo "9.Public IP address if launched with direct addressing; private IP address if launched with public addressing"
echo "10.The ID of the kernel launched with this instance, if applicable"
echo "11.The availability zone in which the instance launched. Same as placement"
echo "12.Product codes associated with this instance"
echo "13.The public hostname of the instance"
echo "14.NATted public IP Address"
echo "15.Public keys Only available if supplied at instance launch time"
echo "16.The ID of the RAM disk launched with this instance, if applicable"
echo "17.ID of the reservation"
echo "18.Names of the security groups the instance is launched in Only available if supplied at instance launch time"
echo "19.User supplied data.Only available if supplied at instance launch time"
echo "20.Exit script"
echo "-----------------"
echo "Enter your Choice"
echo "-----------------"
read Choice
case "$Choice" in
0) echo "Show all metadata information for this host"
ec2-metadata --all ;;
1) echo "The AMI ID used to launch this instance"
ec2-metadata -a ;;
2) echo "The index of this instance in the reservation (per AMI)"
ec2-metadata ;;
3) echo "The manifest path of the AMI with which the instance was launched"
ec2-metadata -m ;;
4) echo "The AMI IDs of any instances that were rebundled to create this AMI"
ec2-metadata -n ;;
5) echo "Defines native device names to use when exposing virtual devices"
ec2-metadata -b ;;
6) echo "The ID of this instance"
ec2-metadata -i ;;
7) echo "The type of instance to launch. For more information, see Instance Types"
ec2-metadata -t ;;
8) echo "The local hostname of the instance"
ec2-metadata -h ;;
9) echo "Public IP address if launched with direct addressing; private IP address if launched with public addressing"
ec2-metadata -o ;;
10) echo "The ID of the kernel launched with this instance, if applicable"
ec2-metadata -k ;;
11) echo "The availability zone in which the instance launched. Same as placement"
ec2metadata -z ;;
12) echo "Product codes associated with this instance"
ec2-metadata -c ;;
13) echo "The public hostname of the instance"
ec2-metadata -p ;;
14) echo "NATted public IP Address"
ec2-metadata -v ;;
15) echo "Public keys Only available if supplied at instance launch time"
ec2-metadata --u ;;
16) echo "The ID of the RAM disk launched with this instance, if applicable"
ec2-metadata --r ;;
17) echo "ID of the reservation"
ec2-metadata -e ;;
18) echo "Names of the security groups the instance is launched in Only available if supplied at instance launch time"
ec2-metadata -s ;;
19) echo "User supplied data.Only available if supplied at instance launch time"
ec2metadata --user-data;;
20) echo "Exiting..........................................."
echo "$var";exit;;
esac