Created
April 13, 2019 06:37
-
-
Save wongcyrus/fe8ced149e9a78dc26b2f9151f7abbb3 to your computer and use it in GitHub Desktop.
Setup aws-visualizer and cloudmapper in Cloud9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo yum install graphviz -y | |
sudo pip install aws-visualizer | |
profilename=worldskills | |
profileregion=us-east-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 | |
aws-dot -p $profilename --directory target/$profilename/default -r $profileregion $@ | |
echo INFO: graphing with subnets | |
aws-dot -p $profilename --directory target/$profilename/subnets -r $profileregion --use-subnets $@ | |
echo INFO: graphing with security groups | |
aws-dot -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 $(sed -e 's/\.dot/\.png/g' <<< $DOTFILE) | |
else | |
echo INFO: Done. checkout target/ subdirectories | |
fi | |
else | |
echo WARN: dot not installed. | |
fi | |
for F in target/*/*/*.dot; do dot -Tpng -o $(dirname $F)/$(basename $F .dot).png $F; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aws configure set profile.worldskills.region us-east-1 | |
aws configure set profile.worldskills.aws_access_key_id XXXXXXXX | |
aws configure set profile.worldskills.aws_secret_access_key YYYYYYYYYYYYYYYYYYY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#No idea why run pipenv install sometimes cannot install the last 3 library and quick is to run it a few times! | |
security_group=$(ec2-metadata -s | cut -d " " -f 2); | |
aws ec2 authorize-security-group-ingress --group-name $security_group --protocol tcp --port 8000 --cidr 0.0.0.0/0 | |
pipenv install --dev --skip-lock | |
sed 's/demo/worldskills/g' config.json.demo > config.json | |
studentAwsAccount=014013008537 | |
sed -i "s/123456789012/$studentAwsAccount/g" config.json | |
pipenv install --dev --skip-lock | |
python3 cloudmapper.py collect --profile worldskills --config config.json --account worldskills | |
python3 cloudmapper.py prepare --config config.json --account worldskills --regions us-east-1 | |
ip=$(curl http://169.254.169.254/latest/meta-data/public-ipv4) | |
echo "Web Server" | |
echo "http://$ip:8000" | |
python3 cloudmapper.py webserver --public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/duo-labs/cloudmapper | |
sudo yum install autoconf automake libtool python3-devel.x86_64 python3-tkinter python-pip jq awscli python34-setuptools -y | |
cd cloudmapper/ | |
pip-3.6 install --user pipenv | |
pipenv install --skip-lock --python 3 | |
pipenv shell --python 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment