aws-inventory/aws-subnet-inventory.sh
2024-04-19 14:09:45 +08:00

17 lines
423 B
Bash
Executable File

#!/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