AWS Resource Tracking Shell Script
DevOps | Cloud Practitioner | AWS | GIT | Kubernetes | Terraform | ArgoCD | Gitlab
Description
This Bash script tracks various AWS resources and saves the output to a file named resourceInfo.txt. It helps DevOps engineers and system administrators keep an inventory of their AWS resources, including S3 buckets, EC2 instances, Lambda functions, and IAM users.
Features
Lists all S3 buckets.
Describes all EC2 instances.
Lists all Lambda functions.
Prints IAM user IDs using
jqfor JSON parsing.Outputs all resource information to
resourceInfo.txt.
Bash Script:
#/bin/bash
#
##Author: Amit
##Date: 5th Jan
##Version: V1
##This script will report AWS resource tracking
#########################
#
set -x # help to run in debug mode
#
##list s3 bucket AWS
echo "print list of s3 bucket"
aws s3 ls > resourceInfo.txt
#
##list ec2 instance
echo "print ec2 instance"
aws ec2 describe-instances >> resourceInfo.txt
#
##list lambda
echo "listing lambda functions"
aws lambda list-functions >> resourceInfo.txt
#
##list IAM USERS
echo "printing IAM users"
aws iam list-users | jq '.Users[].UserId' >> resourceInfo.txt
Prerequisites
Before running this script, ensure the following:
AWS CLI
Install and configure the AWS CLI:aws configurejq
Install thejqtool for JSON parsing:On Ubuntu/Debian:
sudo apt update sudo apt install jqOn RHEL/CentOS:
sudo yum install jq
Bash Shell
The script is designed to run in a Bash environment.
Usage
Clone this repository:
git clone https://github.com/your-username/aws-resource-tracking.git cd aws-resource-trackingMake the script executable:
chmod +x aws_resource_tracking.shRun the script:
./aws_resource_tracking.shView the resource information:
cat resourceInfo.txt
Output
The script generates a file named resourceInfo.txt containing information about:
S3 buckets
EC2 instances
Lambda functions
IAM users



Debugging
The script runs in debug mode (set -x) to display each command as it's executed. You can disable debug mode by removing or commenting out the set -x line.
Notes
Ensure your AWS CLI credentials have the necessary permissions to access the resources.
If
jqis not installed, you can modify the script to usegrepandawkas an alternative.
Author
Amit
Date: January 5th
Version: V1
Feel free to customize this README based on your needs!


