Skip to content

rishis26/aws_resource_tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

AWS Resource Tracker

A lightweight, powerful bash script to monitor and report your AWS resource usage across multiple services in seconds.

Overview

This script provides a comprehensive snapshot of your AWS infrastructure by listing:

  • S3 Buckets - All storage buckets in your account
  • EC2 Instances - Running and stopped compute instances
  • Lambda Functions - Serverless functions and their configurations
  • IAM Users - All user accounts and their details

Why Use This Tool?

Cost Management

Quickly identify unused or forgotten resources that may be costing you money. Spot that S3 bucket you created months ago or EC2 instances left running after testing.

Security Auditing

Regularly review your IAM users and ensure no unauthorized accounts exist. Track who has access to your AWS environment.

Resource Inventory

Get an instant inventory of your AWS resources without logging into the console. Perfect for documentation, compliance reports, or quick checks.

DevOps Efficiency

Integrate into your CI/CD pipelines or cron jobs to maintain automated resource tracking. Great for team visibility and infrastructure monitoring.

Learning & Development

Ideal for developers learning AWS or managing multiple accounts. Understand what resources you have deployed at a glance.

Prerequisites

Before running this script, ensure you have the following installed and configured:

  1. AWS CLI - Install from AWS CLI Installation Guide

    # Verify installation
    aws --version
  2. jq - JSON processor for parsing AWS CLI output

    # macOS
    brew install jq
    
    # Linux (Ubuntu/Debian)
    sudo apt-get install jq
    
    # Verify installation
    jq --version
  3. AWS Credentials - Configure your AWS credentials

    aws configure

    You'll need to provide:

    • AWS Access Key ID
    • AWS Secret Access Key
    • Default region name
    • Default output format (json recommended)

Permissions Required

Your AWS IAM user/role needs the following permissions:

  • s3:ListAllMyBuckets
  • ec2:DescribeInstances
  • lambda:ListFunctions
  • iam:ListUsers

Quick Start

Option 1: Clone the Repository

git clone https://github.com/rishis26/aws_resource_tracker.git
cd aws_resource_tracker
chmod +x aws_resource_tracker.sh
./aws_resource_tracker.sh

Option 2: Direct Download & Run

# Download the script directly
curl -O https://raw.githubusercontent.com/rishis26/aws_resource_tracker/main/aws_resource_tracker.sh

# Make it executable
chmod +x aws_resource_tracker.sh

# Run it
./aws_resource_tracker.sh

Option 3: One-Liner (Download & Execute)

bash <(curl -s https://raw.githubusercontent.com/rishis26/aws_resource_tracker/main/aws_resource_tracker.sh)

What You'll See

The script will display:

  • A list of all S3 bucket names
  • EC2 instance IDs for all instances in your account
  • Details of all Lambda functions
  • Information about all IAM users

Debug output is enabled (set -x), so you'll see each command as it executes.

Example Output

+ echo 'Print list of s3 Buckets'
Print list of s3 Buckets
+ aws s3 ls
2025-01-15 10:30:45 my-bucket-1
2025-02-20 14:22:10 my-bucket-2

+ echo 'Print list of EC2 Instances'
Print list of EC2 Instances
+ aws ec2 describe-instances
+ jq '.Reservations[].Instances[].InstanceId'
"i-1234567890abcdef0"
"i-0987654321fedcba0"

...

Troubleshooting

"aws: command not found"

Install the AWS CLI using the prerequisites section above.

"jq: command not found"

Install jq using the prerequisites section above.

"Unable to locate credentials"

Run aws configure to set up your AWS credentials.

"An error occurred (UnauthorizedOperation)"

Your AWS user/role lacks the necessary permissions. Contact your AWS administrator to grant the required permissions listed above.


Author

Rishi Shah

Version

v2 - 17th November 2025


Pro Tips

  • Run this script regularly (daily/weekly) to stay on top of your AWS resources
  • Redirect output to a file for historical tracking: ./aws_resource_tracker.sh > report_$(date +%Y%m%d).txt
  • Use it before month-end to review resources and optimize costs
  • Combine with other scripts for automated reporting and alerts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages