All  | SeriesTagsYearsAuthors

 

All Posts From (2 Total)

Amazon Elastic Container Service February 2023 round up

Watch the February 2023 Amazon ECS roundup. This monthly segment discusses the latest announcements about Amazon Elastic Container Service.

This episode covered the following topics:

The latest news and announcements about Amazon Elastic Container Service, for the month of February 2023

Delete an ECS task definition using AWS CLI

Installation

Download the script below and use chmod to make it executable:

chmod +x delete-tasks.sh

Script

File: delete-tasks.sh Language: sh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash -ex

TASKNAME=<task name>
START=1 # the first number of the task revision to loop through
END=1000 # The last number to stop the delete loop at

# This function will deregister the task definition
for (( x=$START; x<=$END; x++ ))
do
        aws ecs deregister-task-definition --task-definition $TASKNAME:$x --no-cli-pager
        sleep 5
        echo "The task $TASKNAME and revision $x has been deregistered"
done

# This function will delete the task definition
for (( y=$START; y<=$END; y++ ))
do
        aws ecs delete-task-definitions --task-definitions $TASKNAME:$y --no-cli-pager
        sleep 5
        echo "The task $TASKNAME and revision $y has been deleted"
done

Usage

Modify the following variables to use the script:

A bash script for deleting ECS task definitions using the AWS CLI