Skip to content

Shiwans60/aws-shell-scripting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

AWS Resource Listing Shell Script

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.


Features

  • 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

Technologies Used

  • Bash Shell Scripting
  • AWS CLI v2
  • Ubuntu Linux (EC2)
  • Amazon EC2
  • Git & GitHub

Supported AWS Services

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

Prerequisites

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

Installation

Clone the repository

git clone https://github.com/<your-username>/aws-shell-scripting.git

Go to the project directory

cd aws-shell-scripting

Make the script executable

chmod +x aws_resource_list.sh

Configure AWS CLI

Run

aws configure

Example

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.


Usage

./aws_resource_list.sh <region> <service_name>

Example

./aws_resource_list.sh ap-south-1 ec2

Example Commands

List EC2 Instances

./aws_resource_list.sh ap-south-1 ec2

List S3 Buckets

./aws_resource_list.sh ap-south-1 s3

List Security Groups

./aws_resource_list.sh ap-south-1 security-group

List EBS Volumes

./aws_resource_list.sh ap-south-1 ebs

List IAM Users

./aws_resource_list.sh ap-south-1 iam-user

Sample Output

EC2

Listing EC2 Instances in region ap-south-1...

----------------------------------------------------------
| InstanceId | PrivateIP | PublicIP | State | Type |
----------------------------------------------------------
| *********** | ******** | ******** | running | t3.micro |
----------------------------------------------------------

EBS

Listing EBS Volumes in region ap-south-1...

--------------------------------------------------
| Size | State | VolumeId | VolumeType |
--------------------------------------------------
| 8 | in-use | ******** | gp3 |
--------------------------------------------------

Security Groups

Listing Security Groups in region ap-south-1...

-----------------------------------------------------------------------
| Description | GroupId | GroupName | VpcId |
-----------------------------------------------------------------------
| *********** | ******** | default | ******** |
-----------------------------------------------------------------------

Project Structure

aws-shell-scripting/
│
├── aws_resource_list.sh
├── README.md
└── .gitignore

Learning Outcomes

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

Future Improvements

  • Colored terminal output
  • Logging support
  • Help command
  • Interactive menu
  • Resource filtering
  • Export output to CSV/JSON
  • Error logging

Author

Shiwans Pal

GitHub: https://github.com/Shiwans60

About

This project demonstrates Linux shell scripting, AWS CLI usage, conditional statements, argument validation, and AWS resource management.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages