Skip to content

Latest commit

Β 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 

Repository files navigation

AWS Resource Lister – Shell Script for DevOps Beginners

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.


What This Script Does

  • βœ… 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

Supported AWS Services

You can use the script to list active resources for the following:

  • ec2 – EC2 Instances
  • s3 – S3 Buckets
  • rds – RDS Databases
  • dynamodb – DynamoDB Tables
  • iam – IAM Users
  • cloudformation – Stacks
  • vpc – Virtual Private Clouds
  • lambda – Lambda Functions
  • sns – SNS Topics
  • sqs – SQS Queues

Example Usage

./aws_resource_list.sh us-east-1 ec2
./aws_resource_list.sh ap-south-1 s3

Prerequisites

Before 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

Script Overview

Here’s what the script checks for:

  1. Are two arguments passed? (region & service)
  2. Is AWS CLI installed?
  3. Is AWS CLI configured? (i.e., ~/.aws directory exists)
  4. 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"

File Permissions

To make the script executable:

chmod +x aws_resource_list.sh

For shared environments, you may also restrict read/edit access:

chmod 771 aws_resource_list.sh

This means:

  • Owner and group can read, write, and execute
  • Others can only execute (no read/edit)

Why This Matters

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.


πŸ“˜ Blog Post

Want the full breakdown β€” with every line explained?

πŸ‘‰ Read the full blog on Hashnode


πŸ’¬ Feedback

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

About

A simple yet practical Bash script to list active AWS resources (like EC2, S3, RDS) using the AWS CLI.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages