Skip to content

Instantly share code, notes, and snippets.

@jailbirt
Created February 7, 2023 21:47
Show Gist options
  • Save jailbirt/d55b53b91248314e4801a74abaeb9ea9 to your computer and use it in GitHub Desktop.
Save jailbirt/d55b53b91248314e4801a74abaeb9ea9 to your computer and use it in GitHub Desktop.
list all tags for ecs task-run cluster. For handling according its tags.
#!/bin/bash
tasks_arns=$(aws ecs list-tasks --cluster autoBots| jq -r '.taskArns[]')
for task in $tasks_arns
do
tags=$(aws ecs list-tags-for-resource --resource-arn $task| jq -r '.tags[]' | jq -c '{"key": .key, "value": .value}')
for tag in $tags; do
key=$(echo $tag | jq -r '.key')
value=$(echo $tag | jq -r '.value')
declare "$key=$value"
done
echo "TaskARN: $task"
echo "bot=$bot"
echo "run=$run"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment