Skip to content

Instantly share code, notes, and snippets.

@yannhowe
Created January 26, 2023 09:04
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/d3b22216bb2548f60db641c9615c0b8a to your computer and use it in GitHub Desktop.
Save yannhowe/d3b22216bb2548f60db641c9615c0b8a to your computer and use it in GitHub Desktop.
Get a list of running task definitions and their patch status
#!/bin/bash
aws ecs list-clusters | jq --raw-output 'map(.[])| .[]' | while read -r CLUSTER; do
aws ecs list-tasks --cluster "$CLUSTER" --desired-status RUNNING --launch-type FARGATE --no-paginate | jq --raw-output 'map(.[])| .[]' | while read -r TASK; do
aws ecs describe-tasks --cluster "$CLUSTER" --tasks "$TASK" | jq ".tasks | .[] | .taskDefinitionArn" | awk -F "/" '{print $NF}' | tr -d '"' | while read -r RUNNINGTASKDEFINITION; do
echo "cluster, taskDefinitionArn, patchStatus"
echo -n "$CLUSTER, $RUNNINGTASKDEFINITION, "
# 'Checking for string "/tmp/CrowdStrike/rootfs/entrypoint-ecs.sh" in entrypoint'
if aws ecs describe-task-definition --task-definition "$RUNNINGTASKDEFINITION" | grep -q "/tmp/CrowdStrike/rootfs/entrypoint-ecs.sh"
then
echo patched
else
echo not patched
fi
done
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment