UPD: replaced for loop with parallel
This commit is contained in:
parent
2b3fe2c261
commit
102c2f9c9b
@ -4,7 +4,7 @@
|
|||||||
function list-resources-in-region {
|
function list-resources-in-region {
|
||||||
export AWS_DEFAULT_REGION=$1
|
export AWS_DEFAULT_REGION=$1
|
||||||
echo "---"
|
echo "---"
|
||||||
echo "# Region: $r"
|
echo "# Region: $1"
|
||||||
echo "---"
|
echo "---"
|
||||||
echo -e "\n## EC2:"
|
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 '[\" '
|
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.
|
# 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
|
export -f list-resources-in-region
|
||||||
list-resources-in-region $r > /tmp/aws-inventory-$r.txt &
|
aws --region=us-east-1 ec2 describe-regions --query Regions[].RegionName --output text | sed -e 's/\t/\n/g' | parallel list-resources-in-region {}
|
||||||
done
|
#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..."
|
# echo "This may take a moment..."
|
||||||
sleep 50
|
# sleep 50
|
||||||
|
|
||||||
cat /tmp/aws-inventory*.txt
|
#cat /tmp/aws-inventory*.txt
|
||||||
rm -f /tmp/aws-inventory*.txt
|
#rm -f /tmp/aws-inventory*.txt
|
||||||
|
Loading…
Reference in New Issue
Block a user