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