forked from mvanholsteijn/aws-visualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·62 lines (53 loc) · 1.73 KB
/
run.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
#!/bin/bash
function check_pip_installed() {
PIP=$(which pip)
if [ -z "$PIP" ] ; then
echo ERROR: Python not installed
exit 1
fi
for module in $@ ; do
INSTALLED=$(pip show $module 2>/dev/null)
if [ -z "$INSTALLED" ] ; then
echo ERROR: module $module not installed.
echo ERROR: please run pip install $@
exit 1
fi
done
}
check_pip_installed boto netaddr
if [ ! -f ~/.aws/credentials ] ; then
echo ERROR: ~/.aws/credentials are missing.
echo ' [default]'
echo ' aws_access_key_id = <ACCESS_KEY>'
echo ' aws_secret_access_key = <SECRET_KEY>'
exit 1
fi
read -e -p 'AWS Profile [default]:' profilename
profilename=${profilename:-default}
read -e -p 'AWS Region [eu-central-1]:' profileregion
profileregion=${profileregion:-eu-central-1}
rm -rf target/$profilename
mkdir -p target/$profilename/default
mkdir -p target/$profilename/securitygroups
mkdir -p target/$profilename/subnets
echo INFO: graphing default dependencies
python graph_region.py -p $profilename --directory target/$profilename -r $profileregion $@
echo INFO: graphing with subnets
python graph_region.py -p $profilename --directory target/$profilename/subnets -r $profileregion --use-subnets $@
echo INFO: graphing with security groups
python graph_region.py -p $profilename --directory target/$profilename/securitygroups -r $profileregion --use-security-group-subgraphs $@
DOT=$(which dot)
DOTFILE=$(find target/$profilename -type f -name '*.dot')
if [ -n "$DOT" ] ; then
for file in $DOTFILE; do
echo INFO: generating png for $file
dot -Tpng -o $(dirname $file)/$(basename $file .dot).png $file
done
if [ "$(uname)" == "Darwin" ] ; then
open target/*/*.png
else
echo INFO: Done. checkout target/ subdirectories
fi
else
echo WARN: dot not installed.
fi