From cc01a5449c4ac6a3bc6a46ab1ccea47c84b1e1ec Mon Sep 17 00:00:00 2001 From: x p k Date: Thu, 18 Apr 2024 09:11:00 +0800 Subject: [PATCH] NEW: new inventory scripts for eks, rds, elasticsearch, elasticache --- aws/aws-eks-inventory.sh | 18 ++++++++++++++++++ aws/aws-elasticache-inventory.sh | 16 ++++++++++++++++ aws/aws-elasticsearch-inventory.sh | 16 ++++++++++++++++ aws/aws-rds-inventory.sh | 16 ++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100755 aws/aws-eks-inventory.sh create mode 100755 aws/aws-elasticache-inventory.sh create mode 100755 aws/aws-elasticsearch-inventory.sh create mode 100755 aws/aws-rds-inventory.sh diff --git a/aws/aws-eks-inventory.sh b/aws/aws-eks-inventory.sh new file mode 100755 index 0000000..165635c --- /dev/null +++ b/aws/aws-eks-inventory.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +function listRes() { + aws --region $1 eks list-clusters --query clusters[] --output text | sed -e 's/\t/\n/g' | while read i; do + aws --region $1 eks describe-cluster --name $i | jq -cr '.cluster | [.name, .version] | @csv' | tr -d \" + done +} + +export -f listRes + +# Generate inventory of ec2 in all regions + +echo "ClusterName,ClusterVersion" +aws --region=us-east-1 ec2 describe-regions --query Regions[].RegionName --output text | sed -e 's/\t/\n/g' | while read r; do + sem -j6 listRes $r +done + +sem --wait diff --git a/aws/aws-elasticache-inventory.sh b/aws/aws-elasticache-inventory.sh new file mode 100755 index 0000000..9aa82d2 --- /dev/null +++ b/aws/aws-elasticache-inventory.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +function listRes() { + aws elasticache --region $1 describe-cache-clusters | jq -cr '.CacheClusters[] | [.CacheClusterId, .CacheNodeType, .Engine, .PreferredAvailabilityZone] | @csv' | tr -d \" +} + +export -f listRes + +# Generate inventory of ec2 in all regions + +echo "ClusterId,NodeType,Engine,AZ" +aws --region=us-east-1 ec2 describe-regions --query Regions[].RegionName --output text | sed -e 's/\t/\n/g' | while read r; do + sem -j6 listRes $r +done + +sem --wait diff --git a/aws/aws-elasticsearch-inventory.sh b/aws/aws-elasticsearch-inventory.sh new file mode 100755 index 0000000..a9f58a9 --- /dev/null +++ b/aws/aws-elasticsearch-inventory.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +function listRes() { + aws --region $1 opensearch list-domain-names | jq -cr '.DomainNames[] | [.DomainName, .EngineType] | @csv' | tr -d \" +} + +export -f listRes + +# Generate inventory of ec2 in all regions + +echo "DomainName, EngineType" +aws --region=us-east-1 ec2 describe-regions --query Regions[].RegionName --output text | sed -e 's/\t/\n/g' | while read r; do + sem -j6 listRes $r +done + +sem --wait diff --git a/aws/aws-rds-inventory.sh b/aws/aws-rds-inventory.sh new file mode 100755 index 0000000..b4d37ad --- /dev/null +++ b/aws/aws-rds-inventory.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +function listRes() { + aws rds describe-db-instances --region $1 | jq -cr '.DBInstances[] | [.DBInstanceIdentifier, .DBInstanceClass, .Engine, .AvailabilityZone, .MultiAZ] | @csv' | tr -d \" +} + +export -f listRes + +# Generate inventory of ec2 in all regions + +echo "InstanceId,InstanceClass,Engine,AZ,MultiAz" +aws --region=us-east-1 ec2 describe-regions --query Regions[].RegionName --output text | sed -e 's/\t/\n/g' | while read r; do + sem -j6 listRes $r +done + +sem --wait