Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 37 lines (36 sloc) 1.83 KB
#!/bin/bash
# Keep a local cache of AWS data
# I find it useful to keep the data to grep against, or
# get information that you cant find or search in the console
# Especially IAM keys. Someones IAM keys dont have the right
# perms? Well you cant search the Key in the console, and they
# dont know their username. Well you can find out by doing
# `less ~/AWSCollect/IAMUserKeys` and searching for the key using '/'
#
# Written by Jared Williams <thisis@jared.nyc>
#
# If you have any questions or comments, heres the ways to reach me:
# email: thisis@jared.nyc
# slack: https://devopschat.co signing up is free and my username is @jaredwilliams
# github: @jaredbonobos
# reddit: jaredw
#
# Instructions
# 1. mkdir -p ~/AWSCollect
# 2. install 'jq'. Mac: brew install jq Ubuntu: apt-get install jq Redhat: yum -y install jq
# 3. Make sure you have awscli installed, with ~/.aws or ~/.boto config setup
# 4. Run the script and put in a cron if you want.
#
#
echo "Updating IAMUserKeys"
/usr/local/bin/aws iam list-users | jq '.Users[].UserName' | awk '{print "/usr/local/bin/aws iam list-access-keys --user-name",$1,"--output table"}' | sh > ~/AWSCollect/IAMUserKeys
echo "Updating InstanceInfo"
/usr/local/bin/aws ec2 describe-instances --output table > ~/AWSCollect/InstanceInfo
echo "Updating ECClusterInfo"
/usr/local/bin/aws elasticache describe-cache-clusters --output table > ~/AWSCollect/ECClusterInfo
echo "Updating S3BucketList"
/usr/local/bin/aws s3 ls --output text > ~/AWSCollect/S3BucketList
echo "Updating Route53Zones"
/usr/local/bin/aws route53 list-hosted-zones --output json | jq -S '(.HostedZones[].Id)' | awk '{print "/usr/local/bin/aws route53 list-resource-record-sets --hosted-zone-id",$1,"--output table"}' | sh > ~/AWSCollect/Route53Zones
echo "Updating ELBInfo"
/usr/local/bin/aws elb describe-load-balancers --output table > ~/AWSCollect/ELBInfo