Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Razzendah/cbb5c393fbc65af9df5590071f7722b3 to your computer and use it in GitHub Desktop.
Save Razzendah/cbb5c393fbc65af9df5590071f7722b3 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment