-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaws_resource_list.sh
More file actions
executable file
·114 lines (97 loc) · 3.22 KB
/
aws_resource_list.sh
File metadata and controls
executable file
·114 lines (97 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
###################################################################################
#This script list the AWS resources used by the account.
#Author : Priyanka
#Date: Nov 27, 24
#Version : 1
#
#Services to be supported in this script:
#EC2, S3, RDS, DynamoDB, Lambda, EBS, ELB, CloudFront, SNS, SQS, Route53, VPC, CloudFormation, IAM
#
#Usage: ./aws_resource_list.sh <region> <servicename>
#
####################################################################################
#
#
#
# Check if the required number of arguments are passed
if [ $# -ne 2 ]; then
echo "Uage: $0 <region> <servicename>"
exit 1
fi
#assign the agruments to variables and convert the service to lowercase
aws_region=$1
aws_service=$(echo "$2" | tr '[:upper:]' '[:lower:]')
#Check if AWS CLI is installed
if ! command -v aws &> /dev/null; then
echo "AWS CLI is not installed. Please install the AWS CLI and then try again"
exit 1
fi
# Check if AWS CLI is configured
if [ ! -d ~/.aws ]; then
echo "AWS CLI is not configured. Please configure AWS CLI and then try again."
exit 1
fi
# List the resources based on the service
case $aws_service in
ec2)
echo "Listiong EC2 instances in $aws_region"
aws ec2 describe-instances --region $aws_region
;;
rds)
echo "Listiong RDS instances in $aws_region"
aws rds describe-db-instances --region $aws_region
;;
s3)
echo "Listiong S3 busckets in $aws_region"
aws s3api list-buckets --region $aws_region
;;
cloudfront)
echo "Listing CloudFront Distributions in $aws_region"
aws cloudfront list-distributions --region $aws_region
;;
vpc)
echo "Listing VPCs in $aws_region"
aws ec2 describe-vpcs --region $aws_region
;;
iam)
echo "Listing IAM users in $aws_region"
aws iam list-users --region $aws_region
;;
route5)
echo "Listing Route53 Hosted Zones in $aws_region"
aws route53 list-hosted-zones --region $aws_region
;;
cloudwatch)
echo "Listing CloudWatch alarms in $aws_region"
aws cloudwatch describe-alarms --region $aws_region
;;
cloudformation)
echo "Listing CloudFormation stacks in $aws_region"
aws cloudformation describe-stacks --region $aws_region
;;
lambda)
echo "Listing Lambda Functions in $aws_region"
aws lambda list-functions --region $aws_region
;;
sns)
echo "Listing SNS Topics in $aws_region"
aws sns list-topics --region $aws_region
;;
sqs)
echo "Listing SQS Queues in $aws_region"
aws sqs list-queues --region $aws_region
;;
dynamodb)
echo "Listing DynamoDB Tables in $aws_region"
aws dynamodb list-tables --region $aws_region
;;
ebs)
echo "Listing EBS Volumes in $aws_region"
aws ec2 describe-volumes --region $aws_region
;;
*)
echo "Invalid Service. Please enter a valid service."
exit 1
;;
esac