Created
February 29, 2024 04:33
-
-
Save yannhowe/d77e7cee67415ba1a9ee17663a9f1f2f to your computer and use it in GitHub Desktop.
Count ECS Fargate Tasks in Account for default region
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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