Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to deregister all ECS Task Definitions in a given region
#!/usr/bin/env bash
get_task_definition_arns() {
aws ecs list-task-definitions --region ${AWS_REGION} \
| jq -M -r '.taskDefinitionArns | .[]'
}
delete_task_definition() {
local arn=$1
aws ecs deregister-task-definition \
--region us-east-2 \
--task-definition "${arn}" > /dev/null
}
if [ -z "${AWS_REGION}" ] ; then
(>&2 echo "AWS_REGION is not set")
exit 1
fi
for arn in $(get_task_definition_arns)
do
echo "Deregistering ${arn}..."
delete_task_definition "${arn}"
done
@anna-anisienia

This comment has been minimized.

Copy link

@anna-anisienia anna-anisienia commented Aug 1, 2020

thanks for sharing, very helpful!

@klang

This comment has been minimized.

Copy link

@klang klang commented Sep 16, 2020

Worked like a charm, when deregistering task definitions from the console didn't play ball.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment