Sign inSign up

clausa/awless-datasette

By clausa

•Updated over 7 years ago

Simple web-ui for AWS inventory browsing and querying using awless and datasette

Image
1

309

clausa/awless-datasette repository overview

Combining awless⁠ and datasette⁠ to create a simple interface for browsing and querying your AWS infrastructure inventory.

⁠Run

docker run -v ~/.aws:/root/.aws -p 8001:8001 -ti clausa/awless-datasette [aws-profilenames]

[aws-profilenames] is a comma separated list of the profile names in your ~/.aws/credentials file you want to inventory.

Finally browse http://127.0.0.1:8001⁠

⁠Dockerfile

FROM python:3-stretch

RUN apt-get update && apt-get -y dist-upgrade
RUN apt-get -y install less jq wget
RUN wget https://github.com/wallix/awless/releases/download/v0.1.11/awless-linux-amd64.tar.gz
RUN tar zxvf awless-linux-amd64.tar.gz && rm awless-linux-amd64.tar.gz && chmod +x /awless
RUN pip install datasette
RUN pip install csvs-to-sqlite

COPY entrypoint.sh /

EXPOSE 8001

ENTRYPOINT ["/entrypoint.sh"]

⁠entrypoint.sh

#!/bin/bash

if [ "x$1" == "x"  ]; then
    echo "Please provide a comma seperated list of aws account profile names that matches an entry in ~/aws.credentials"
    exit 1
fi

AWSSERVICES="accesskeys alarms availabilityzones buckets certificates classicloadbalancers containerclusters containerinstances containers containertasks databases dbsubnetgroups distributions elasticips functions groups images importimagetasks instanceprofiles instances internetgateways keypairs launchconfigurations listeners loadbalancers metrics mfadevices natgateways networkinterfaces policies queues records repositories roles routetables s3objects scalinggroups scalingpolicies securitygroups snapshots stacks subnets subscriptions targetgroups topics users volumes vpcs zones"

IFS=', ' read -r -a AWSACCOUNTS <<< $1

for AWSACCOUNT in "${AWSACCOUNTS[@]}"; do
    echo $AWSACCOUNT
    mkdir -p /tmp/csvs/$AWSACCOUNT
    for AWSSERVICE in $AWSSERVICES; do
	/awless -p $AWSACCOUNT list $AWSSERVICE --format csv > /tmp/csvs/$AWSACCOUNT/$AWSSERVICE.csv
    done
done

echo "Removing CSV files without data"
for AWSACCOUNT in "${AWSACCOUNTS[@]}"; do
    for x in `ls -1 /tmp/csvs/$AWSACCOUNT/*.csv`; do
	wc -l $x | grep -q -e '0 ' -e '1 ' && rm -f $x
    done
done

DATABASES=""
echo "Creating sqlite database from CSV files"
for AWSACCOUNT in "${AWSACCOUNTS[@]}"; do
    csvs-to-sqlite /tmp/csvs/$AWSACCOUNT/*.csv /tmp/$AWSACCOUNT.db
    DATABASES="/tmp/$AWSACCOUNT.db $DATABASES"
    echo $DATABASES
done

echo "Staring datasette with awless generated database"
datasette serve -h 0.0.0.0 $DATABASES

Tag summary

Content type

Image

Digest

Size

462.1 MB

Last updated

over 7 years ago

docker pull clausa/awless-datasette