aws-inventory/aws-ecs-inventory.sh

17 lines
539 B
Bash
Raw Normal View History

2024-04-19 14:09:45 +08:00
#!/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