🚀 As a beginner in DevOps, I recently completed an insightful shell scripting project following the guidance from @AbhishekVeeramalla's channel. This project has been instrumental in helping me understand both AWS resource management and shell scripting fundamentals. Let me share what I learned and built!
📋 Project Overview
The project involves creating a shell script that lists various AWS resources across different services. It's particularly useful for DevOps engineers who need to quickly audit or check resources across their AWS infrastructure.
🎯 What Problem Does It Solve?
In AWS environments, resources can proliferate across different services, making it challenging to maintain visibility. This script provides a quick way to list resources from various AWS services like EC2, S3, RDS, Lambda, and more, all from the command line.
🛠️ Technical Implementation
✅ Prerequisites
- AWS CLI installed and configured
- Basic understanding of shell scripting
- AWS account with appropriate permissions
💻 The Script
Here's the complete implementation of our AWS resource listing script:
#!/bin/bash
########################################
# AWS Resource Listing Script
# Author: Setcuko
# Version: v0.0.1
#
# Supported AWS services:
# - EC2
# - S3
# - DynamoDB
# - Lambda
# - EBS
# - CloudWatch
# - SNS
# - VPC
# - CloudFormation
# - IAM
########################################
# Parameter validation
if [ $# -ne 2 ]; then
echo "Usage: ./aws_resource_list.sh <aws_region> <aws_service>"
echo "Example: ./aws_resource_list.sh us-east-1 ec2"
exit 1
fi
# Assign arguments to variables
aws_region=$1
aws_service=$2
# AWS CLI installation check
if ! command -v aws &> /dev/null; then
echo "AWS CLI is not installed. Please install the AWS CLI and try again."
exit 1
fi
# AWS CLI configuration check
if [ ! -d ~/.aws ]; then
echo "AWS CLI is not configured. Please configure the AWS CLI and try again."
exit 1
fi
# Main logic for resource listing
case $aws_service in
ec2)
echo "Listing EC2 Instances in $aws_region"
aws ec2 describe-instances --region $aws_region
;;
# ... [other service cases]
esac
⭐ Key Features
-
Service Support: The script supports multiple AWS services including:
- 🖥️ EC2 instances
- 🪣 S3 buckets
- 📊 DynamoDB tables
- ⚡ Lambda functions
- 💾 EBS volumes
- 📈 CloudWatch alarms
- 📱 SNS topics
- 🌐 VPC resources
- 🏗️ CloudFormation stacks
- 👥 IAM users
We can add further based on our requirement
-
Input Validation: The script checks for:
- ✅ Correct number of parameters
- ✅ AWS CLI installation
- ✅ AWS CLI configuration
Region-specific: 🌍 Allows checking resources in any AWS region
🔧 Run command
# List EC2 instances in us-east-1
./aws_resource_list.sh us-east-1 ec2
🙏 Acknowledgments
Special thanks to @AbhishekVeeramalla for providing such clear and practical guidance through his channel. His DevOps tutorials have been instrumental in helping me understand both the theoretical and practical aspects of AWS and shell scripting.
🎉 Conclusion
This project, while seemingly simple, provides a solid foundation in both AWS resource management and shell scripting. It's a practical tool that can be used in real-world scenarios and serves as a great learning exercise for DevOps beginners.
Would love to hear your thoughts and suggestions for improvements! Feel free to comment below or reach out to discuss more DevOps practices. 💡
Top comments (0)