Track Your AWS Resources Like a Pro — With a Simple Bash Script

Managing cloud infrastructure can get overwhelming. With resources like S3 buckets, IAM users, and EC2 instances scattered across your AWS account, it’s hard to keep track of everything. This simple tool, the AWS Resource Tracker, solves this problem by automating the tracking and logging of your AWS resources.

✅ No need for Python ✅ No external dependencies ✅ Just Bash and AWS CLI

🧰 What It Does

This script collects a snapshot of key AWS resources and logs the data into timestamped files. It’s perfect for audits, monitoring resource usage, and keeping track of your AWS environment.

📋 Features:

  • Lists all S3 buckets
  • Lists all IAM users
  • Lists all EC2 instances
  • Saves results to a timestamped log file
  • Can be scheduled to run daily/weekly with cron

🧱 Folder Structure

Here’s what the project folder looks like:

aws-resource-tracker/
│
├── aws_resource_tracker.sh         # Main script
├── logs/                           # Output log files
└── README.md                       # Project docs        

⚙️ Prerequisites

Before you run the script, ensure the following:

  1. AWS CLI installed and configured:
  2. If you don’t have AWS CLI set up, install and configure it:

aws configure        

  1. Ensure you have IAM permissions to run s3, iam, and ec2 commands.
  2. A Bash shell (works on Linux, macOS, or Windows using WSL).

🚀 Getting Started

Step 1: Clone the Repo or Download the Script

If you’re cloning from GitHub:

git clone https://github.com/Hetpatel7131/aws-resource-tracker.git        

Or, download the aws_resource_tracker.sh file and place it in your desired directory. GitHub repo: link

Article content

Step 2: Make the Script Executable

To make the script executable, run this command:

chmod +x aws_resource_tracker.sh        

Step 3: Run the Script

Now, execute the script:

./aws_resource_tracker.sh        

Sample Output

The script will generate logs in the logs/ folder. The log file will be timestamped, like so:

logs/aws_resource_tracker_2025-04-14_22-40.log        

Every time the script runs, a new log file is created.

⏰ Automate the Script with Cron

To run this script daily at 22:46 PM, follow these steps:

Step 1: Open Your Crontab

crontab -e        

Step 2: Add the Cron Job

Add the following line to schedule the script:

46 22 * * * /path/to/aws-resource-tracker/aws_resource_tracker.sh >> /path/to/aws-resource-tracker/logs/cron_output.log 2>&1        

This cron job will run the script at 22:46 PM every day and log the output to cron_output.log.

Article content

Step 3: Save and Exit

Save the file and exit the editor. Now, the script will run automatically at the scheduled time.

🤝 Connect With Me

Feel free to reach out, follow, or connect for more cloud tips, DevOps practices, and open-source projects!

To view or add a comment, sign in

More articles by Het Patel

Explore content categories