-
-
Save Razzendah/cbb5c393fbc65af9df5590071f7722b3 to your computer and use it in GitHub Desktop.
Script to deregister all ECS Task Definitions in a given region
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
#!/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