Skip to content

Instantly share code, notes, and snippets.

@yannhowe
Created February 29, 2024 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yannhowe/d77e7cee67415ba1a9ee17663a9f1f2f to your computer and use it in GitHub Desktop.
Save yannhowe/d77e7cee67415ba1a9ee17663a9f1f2f to your computer and use it in GitHub Desktop.
Count ECS Fargate Tasks in Account for default region
#!/bin/bash
clusters=$(aws ecs list-clusters --query 'clusterArns' --output text)
total_tasks=0
for cluster in $clusters; do
task_count=$(aws ecs list-tasks --cluster $cluster --query 'length(taskArns[])')
total_tasks=$((total_tasks + task_count))
done
echo "Total ECS tasks in all clusters in the account, region: $total_tasks"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment