Hey there!
This is a companion script to my blog post where I documented my journey of writing a real-world shell script that interacts with AWS.
Goal:
List active AWS resources (like EC2, S3, Lambda, etc.) for a given region and service — in a simple, beginner-friendly way.
This may look like a small script, but it reflects a common DevOps use case — scripts like this often run daily via cron to track infrastructure usage and cost.
- ✅ Accepts a region and service name as input
- ✅ Validates the input and environment
- ✅ Checks if AWS CLI is installed and configured
- ✅ Lists live resources for supported AWS services
- ✅ Provides clear and helpful messages for beginners
You can use the script to list active resources for the following:
ec2– EC2 Instancess3– S3 Bucketsrds– RDS Databasesdynamodb– DynamoDB Tablesiam– IAM Userscloudformation– Stacksvpc– Virtual Private Cloudslambda– Lambda Functionssns– SNS Topicssqs– SQS Queues
./aws_resource_list.sh us-east-1 ec2
./aws_resource_list.sh ap-south-1 s3Before using this script, make sure:
- ✅ AWS CLI is installed
- ✅ You've configured your credentials using
aws configure - ✅ You have the required permissions for the AWS services you're querying
Here’s what the script checks for:
- Are two arguments passed? (region & service)
- Is AWS CLI installed?
- Is AWS CLI configured? (i.e.,
~/.awsdirectory exists) - Is the service supported? If yes → run the relevant AWS CLI command
Each service has a specific command under the hood, like:
aws ec2 describe-instances --region "$1"
aws s3 ls --region "$1"
aws rds describe-db-instances --region "$1"To make the script executable:
chmod +x aws_resource_list.shFor shared environments, you may also restrict read/edit access:
chmod 771 aws_resource_list.shThis means:
- Owner and group can read, write, and execute
- Others can only execute (no read/edit)
This project is about more than just scripting.
It’s about:
- Moving from learning syntax → to building something real
- Thinking about usability, validation, and reliability
- Practicing DevOps habits — clarity, structure, and automation
Even a small script like this can save hours, reduce confusion, and improve visibility into your cloud resources.
Want the full breakdown — with every line explained?
👉 Read the full blog on Hashnode
If you're learning DevOps or shell scripting and this helped, feel free to:
⭐ Drop a star
🍴 Fork it
📬 Or reach out on GitHub or LinkedIn
I'm learning too — always happy to connect with others on the same path.
Thanks for stopping by!
— Arnab