Created
January 26, 2023 09:04
-
-
Save yannhowe/d3b22216bb2548f60db641c9615c0b8a to your computer and use it in GitHub Desktop.
Get a list of running task definitions and their patch status
This file contains 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 | |
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