UPD: replaced for loop with parallel
This commit is contained in:
parent
2b3fe2c261
commit
102c2f9c9b
@ -4,7 +4,7 @@
|
||||
function list-resources-in-region {
|
||||
export AWS_DEFAULT_REGION=$1
|
||||
echo "---"
|
||||
echo "# Region: $r"
|
||||
echo "# Region: $1"
|
||||
echo "---"
|
||||
echo -e "\n## EC2:"
|
||||
aws ec2 describe-instances --query 'Reservations[*].Instances[*].[InstanceId, Tags[?Key==`Name`].Value[] | [0], PlatformDetails, InstanceType,PrivateIpAddress]' --output json | jq -cr '.[][] | @tsv' | tr -d '[\" '
|
||||
@ -41,12 +41,14 @@ function list-resources-in-region {
|
||||
}
|
||||
|
||||
# Generate inventory of ec2, rds, lb, and s3 buckets.
|
||||
aws --region=us-east-1 ec2 describe-regions --query Regions[].RegionName --output text | sed -e 's/\t/\n/g' | while read r; do
|
||||
list-resources-in-region $r > /tmp/aws-inventory-$r.txt &
|
||||
done
|
||||
export -f list-resources-in-region
|
||||
aws --region=us-east-1 ec2 describe-regions --query Regions[].RegionName --output text | sed -e 's/\t/\n/g' | parallel list-resources-in-region {}
|
||||
#aws --region=us-east-1 ec2 describe-regions --query Regions[].RegionName --output text | sed -e 's/\t/\n/g' | while read r; do
|
||||
# list-resources-in-region $r > /tmp/aws-inventory-$r.txt &
|
||||
#done
|
||||
|
||||
echo "This may take a moment..."
|
||||
sleep 50
|
||||
# echo "This may take a moment..."
|
||||
# sleep 50
|
||||
|
||||
cat /tmp/aws-inventory*.txt
|
||||
rm -f /tmp/aws-inventory*.txt
|
||||
#cat /tmp/aws-inventory*.txt
|
||||
#rm -f /tmp/aws-inventory*.txt
|
||||
|
Loading…
Reference in New Issue
Block a user