NEW: Initial release
This commit is contained in:
commit
122fe95f95
|
@ -0,0 +1,12 @@
|
|||
# aws-inventory
|
||||
Scripts to collect AWS resource inventory in all regions.
|
||||
|
||||
## Requirements
|
||||
- bash
|
||||
- awscli
|
||||
- gnu parallel
|
||||
- miller
|
||||
|
||||
## Usage
|
||||
Run run-inventory-scripts.sh which will invoke a collection of scripts. TSV is returned for visibility.
|
||||
Individual script can be ran to produce inventory of specific service. CSV is returned for programatic use.
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
|
||||
function formatprint() {
|
||||
cat - > /tmp/formatprint.tmp
|
||||
echo "# $1 ($(cat /tmp/formatprint.tmp | wc -l))"
|
||||
#cat /tmp/formatprint.tmp | sed -e 's/^/ /g'
|
||||
cat /tmp/formatprint.tmp | column -t -s, | sed -e 's/^/ /g'
|
||||
rm -f /tmp/formatprint.tmp
|
||||
}
|
||||
|
||||
function listEc2() {
|
||||
aws --region=$1 ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, Tags[?Key==`Name`].Value[] | [0], PlatformDetails, InstanceType,PrivateIpAddress, Placement.AvailabilityZone]' --output json | jq -cr '.[][] | @csv' | tr -d '[\" '
|
||||
}
|
||||
|
||||
export -f formatprint
|
||||
export -f listEc2
|
||||
|
||||
# Generate inventory of ec2 in all regions
|
||||
|
||||
echo "InstanceId,NameTag,OsPlatform,InstanceType,PrivateIp,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 listEc2 $r
|
||||
done
|
||||
|
||||
sem --wait
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
function listRes() {
|
||||
aws --region $1 ecs list-clusters | jq -cr '.clusterArns[]' | parallel aws --region $1 ecs describe-clusters --clusters {} | jq -cr '.clusters[] | [.clusterName, .runningTasksCount, .capacityProviders[0]] | @csv' | tr -d \"
|
||||
}
|
||||
|
||||
export -f listRes
|
||||
|
||||
# Generate inventory of ec2 in all regions
|
||||
|
||||
echo "ClusterName, TasksCount, CapacityProvider"
|
||||
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
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
function listRes() {
|
||||
aws --region $1 efs describe-file-systems | jq -cr '.FileSystems[] | [.FileSystemId, .Name, .PerformanceMode, (.SizeInBytes.Value/1024/1024)] | @csv' | tr -d \"
|
||||
}
|
||||
|
||||
export -f listRes
|
||||
|
||||
# Generate inventory in all regions
|
||||
|
||||
echo "FilesystemId, Name, PerformanceMode, SizeMb"
|
||||
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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
function listRes() {
|
||||
aws --region $1 elbv2 describe-load-balancers | jq -cr '.LoadBalancers[] | [.LoadBalancerName, .Scheme, .Type, .AvailabilityZones[0].ZoneName] | @csv' | tr -d \"
|
||||
}
|
||||
|
||||
export -f listRes
|
||||
|
||||
# Generate inventory in all regions
|
||||
|
||||
echo "LbName,Scheme,Type,AZ1"
|
||||
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
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
function listRes() {
|
||||
aws --region $1 emr list-clusters --query Clusters[].Id --output text | sed 's/\t/\n/g' | while read i; do
|
||||
aws --region $1 emr describe-cluster --cluster-id $i | jq -cr '.Cluster | [.Id, .Name, .ReleaseLabel, .Ec2InstanceAttributes.Ec2AvailabilityZone] | @csv' | tr -d \"
|
||||
done
|
||||
}
|
||||
|
||||
export -f listRes
|
||||
|
||||
# Generate inventory of ec2 in all regions
|
||||
|
||||
echo "ClusterId,ClusterName,ReleaseLabel,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
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
function listRes() {
|
||||
aws --region $1 lambda list-functions | jq -cr '.Functions[] | [.FunctionName, .Runtime, .Architectures[]] | @csv' | tr -d \"
|
||||
}
|
||||
|
||||
export -f listRes
|
||||
|
||||
# Generate inventory in all regions
|
||||
|
||||
echo "FunctionName, Runtime, Architecture"
|
||||
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
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
function listRes() {
|
||||
aws --region $1 logs describe-log-groups | jq -cr '.logGroups[] | [.logGroupName, .retentionInDays, .logGroupClass] | @csv' | tr -d \"
|
||||
}
|
||||
|
||||
export -f listRes
|
||||
|
||||
# Generate inventory in all regions
|
||||
|
||||
echo "LogGroup, Retention, Class"
|
||||
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
|
|
@ -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
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "ZoneName, IsPrivate, RecordCount"
|
||||
aws route53 list-hosted-zones | jq -cr '.HostedZones[] | [.Name, .Config.PrivateZone, .ResourceRecordSetCount] | @csv' | tr -d \"
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Generate inventory in all regions
|
||||
echo "BucketName"
|
||||
aws s3api list-buckets --query Buckets[].Name --output text | sed 's/\t/\n/g'
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
function listRes() {
|
||||
aws --region $1 ec2 describe-subnets | jq -cr '.Subnets[] | [.SubnetId, .VpcId, .CidrBlock, .AvailabilityZone] | @csv' | tr -d \"
|
||||
}
|
||||
|
||||
export -f listRes
|
||||
|
||||
# Generate inventory in all regions
|
||||
|
||||
echo "SubnetId,VpcId,CidrBlock,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
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
for i in aws*.sh; do
|
||||
echo "# $i"
|
||||
bash $i | mlr --c2t cat | column -t
|
||||
wait $!
|
||||
done
|
Loading…
Reference in New Issue