Skip to content

Instantly share code, notes, and snippets.

@yannhowe
yannhowe / gist:d77e7cee67415ba1a9ee17663a9f1f2f
Created February 29, 2024 04:33
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"
@yannhowe
yannhowe / count_azure_aci.sh
Created July 23, 2024 09:46
Count Azure ACI containers
#!/bin/bash
# Count ACI containers
RESOURCE_GROUP=""
TOTAL_CONTAINERS=0
CONTAINER_COUNT=0
echo "\$CONTAINER_RESOURCEGROUP | \$CONTAINER_NAME | \$CONTAINER_COUNT"
while IFS=$'\t' read -r CONTAINER_NAME CONTAINER_RESOURCEGROUP ; do