A Bash script that lists AWS resources using the AWS CLI. The script accepts an AWS region and a service name as input and displays the corresponding AWS resources in a formatted table.
This project demonstrates Linux shell scripting, AWS CLI usage, conditional statements, argument validation, and AWS resource management.
- Lists resources from multiple AWS services
- Accepts AWS Region and Service Name as command-line arguments
- Validates user input
- Checks whether AWS CLI is installed
- Checks whether AWS CLI is configured
- Displays output in a readable table format
- Easy to extend with additional AWS services
- Bash Shell Scripting
- AWS CLI v2
- Ubuntu Linux (EC2)
- Amazon EC2
- Git & GitHub
| Service | Command |
|---|---|
| EC2 Instances | ec2 |
| S3 Buckets | s3 |
| RDS Instances | rds |
| Lambda Functions | lambda |
| CloudFormation Stacks | cloudformation |
| VPCs | vpc |
| Security Groups | security-group |
| IAM Users | iam-user |
| IAM Roles | iam-role |
| CloudWatch Alarms | cloudwatch-alarm |
| CloudTrail Trails | cloudtrail |
| SNS Topics | sns |
| SQS Queues | sqs |
| EBS Volumes | ebs |
| Elastic Load Balancers | elb |
Before running the script, ensure that:
- AWS CLI v2 is installed
- AWS CLI is configured
- Valid AWS credentials are configured
- Bash shell is available
- Required IAM permissions are granted
Clone the repository
git clone https://github.com/<your-username>/aws-shell-scripting.gitGo to the project directory
cd aws-shell-scriptingMake the script executable
chmod +x aws_resource_list.shRun
aws configureExample
AWS Access Key ID [None]: ********************
AWS Secret Access Key [None]: ********************
Default region name [None]: ap-south-1
Default output format [None]: json
Do not share your AWS Access Key or Secret Access Key publicly.
./aws_resource_list.sh <region> <service_name>Example
./aws_resource_list.sh ap-south-1 ec2./aws_resource_list.sh ap-south-1 ec2./aws_resource_list.sh ap-south-1 s3./aws_resource_list.sh ap-south-1 security-group./aws_resource_list.sh ap-south-1 ebs./aws_resource_list.sh ap-south-1 iam-userListing EC2 Instances in region ap-south-1...
----------------------------------------------------------
| InstanceId | PrivateIP | PublicIP | State | Type |
----------------------------------------------------------
| *********** | ******** | ******** | running | t3.micro |
----------------------------------------------------------
Listing EBS Volumes in region ap-south-1...
--------------------------------------------------
| Size | State | VolumeId | VolumeType |
--------------------------------------------------
| 8 | in-use | ******** | gp3 |
--------------------------------------------------
Listing Security Groups in region ap-south-1...
-----------------------------------------------------------------------
| Description | GroupId | GroupName | VpcId |
-----------------------------------------------------------------------
| *********** | ******** | default | ******** |
-----------------------------------------------------------------------
aws-shell-scripting/
│
├── aws_resource_list.sh
├── README.md
└── .gitignore
This project helped me understand:
- Linux shell scripting
- Bash conditional statements
- Case statements
- Command-line arguments
- AWS CLI
- AWS authentication
- EC2 management
- IAM basics
- Linux file permissions
- Git & GitHub workflow
- Colored terminal output
- Logging support
- Help command
- Interactive menu
- Resource filtering
- Export output to CSV/JSON
- Error logging
Shiwans Pal
GitHub: https://github.com/Shiwans60